6 (:message
(:string
:free-from-foreign nil
)))
8 (defcfun g-error-new-literal
:pointer
13 (defcfun g-error-free
:void
16 (defcfun g-error-copy
:pointer
19 (defcfun g-error-matches
:boolean
24 (defcfun g-set-error-literal
:void
30 (defcfun g-propagate-error
:void
34 (defcfun g-clear-error
:void
37 (define-condition g-error-condition
(error)
38 ((domain :initarg
:domain
:initform nil
:reader g-error-condition-domain
)
39 (code :initarg
:code
:initform nil
:reader g-error-condition-code
)
40 (message :initarg
:message
:initform nil
:reader g-error-condition-message
))
41 (:report
(lambda (e stream
)
42 (format stream
"GError was raised. Domain: ~S, code: ~S, message: ~A"
43 (g-error-condition-domain e
)
44 (g-error-condition-code e
)
45 (g-error-condition-message e
)))))
47 (defun mayber-raise-g-error-condition (err)
48 (unless (null-pointer-p err
)
49 (error 'g-error-condition
50 :domain
(foreign-slot-value err
'g-error
:domain
)
51 :code
(foreign-slot-value err
'g-error
:code
)
52 :message
(foreign-slot-value err
'g-error
:message
))))
54 (defmacro with-g-error
((err) &body body
)
55 `(with-foreign-object (,err
:pointer
)
56 (setf (mem-ref ,err
:pointer
) (null-pointer))
59 (mayber-raise-g-error-condition (mem-ref ,err
:pointer
))
60 (g-clear-error ,err
))))
62 (defmacro with-catching-to-g-error
((err) &body body
)
65 (g-error-condition (e)
66 (g-set-error-literal ,err
67 (g-error-condition-domain e
)
68 (g-error-condition-code e
)
69 (g-error-condition-message e
)))))
71 ;; void g_prefix_error (GError **err,
72 ;; const gchar *format,
74 ;; void g_propagate_prefixed_error (GError **dest,
76 ;; const gchar *format,