Esempio n. 1
0
func gErrorToGoError(gerr *C.GError) error {
	if gerr == nil {
		return errors.New("Poppler/GLib: unknown error")
	}

	defer C.g_error_free(gerr)

	message := C.GoString((*C.char)(gerr.message))
	if message == "No error" {
		// Work around inconsistent error message when named file doesn't exist.
		quarkString := C.GoString((*C.char)(C.g_quark_to_string(gerr.domain)))
		if "g-file-error-quark" == quarkString {
			return fmt.Errorf("Poppler/GLib: file error, code %d", gerr.code)
		}
		return fmt.Errorf("Poppler/GLib: unknown error, domain %d, code %d", gerr.domain, gerr.code)
	}

	return fmt.Errorf("Poppler/GLib: %s", C.GoString((*C.char)(gerr.message)))
}
Esempio n. 2
0
func (q Quark) String() string {
	return C.GoString((*C.char)(C.g_quark_to_string(q.GQuark())))
}