-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Currently GLib has GException which is thrown if an error occurs in C:
| public sealed partial class GException : Exception, IDisposable |
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.
Compare the ConvertError domain: https://docs.gtk.org/glib/error.ConvertError.html
See generated ConvertError enum: https://gircore.github.io/api/GLib.ConvertError.html
Using generics could potentially be hard if the domain is unknown during compile time.