GLib errors contain a domain and error code in addition to its message.
Derive from GException and create GException<T> with a property Code of type T.
The libraries define their error domains as enums which map to error domains. If an error is received we can get the domain code, map it to the corresponding enum and convert the error code into an enum value.
A user catching GException<ConvertError> can get the specific error from the Code property.
Currently GLib has
GException
which is thrown if an error occurs in C:https://github.com/gircore/gir.core/blob/712ab1740ca138a9a6dcd36975e2302b0a58f8d0/src/Libs/GLib-2.0/Public/Exception.cs#L6
GLib errors contain a domain and error code in addition to its message.
Derive from
GException
and createGException<T>
with a propertyCode
of typeT
.The libraries define their error domains as enums which map to error domains. If an error is received we can get the domain code, map it to the corresponding enum and convert the error code into an enum value.
A user catching
GException<ConvertError>
can get the specific error from theCode
property.Compare the
ConvertError
domain: https://docs.gtk.org/glib/error.ConvertError.htmlSee generated
ConvertError
enum: https://gircore.github.io/api/GLib.ConvertError.htmlUsing generics could potentially be hard if the domain is unknown during compile time.