-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider using enum error code instead of nested exception types #71
Comments
In exploring the possibility of unique sets of fields for each error enum member, I discovered that UDL can express such enums:
But uniffi-bindgen-cs generates uncompilable C# code when I reference this type in a |
This worked:
So I like that you have nested exception types now, since they capture the fields on the enumerated error. |
We could think about generating But if you don't see this as a problem anymore, maybe there is no reason to change how errors are implemented. |
Well, it may be a good idea still, but there's value enough in the exception details that I've now discovered how to unlock that I don't think it'll be a wish item for me. It's #41 that I really want. And I'm an expert in async... if only I had time to research the uniffi protocol itself, I'd send you a PR to add async support. |
An enum error type in UDL produces a C# exception with a nested derived exception type for each enum value.
For example:
But these exception types don't hold any unique properties. Why not nest this inside the exception instead?
It results in less metadata. And in .NET in general, very finely grained exception types are discouraged. The enum approach still allows exception filters to catch specific cases. For example:
This is all assuming that UDL doesn't support carrying distinct error enums data across the interop boundary. If different error enum values can actually carry distinct fields in UDL (as they can in rust) then C# should probably retain a distinct exception type for each one.
The text was updated successfully, but these errors were encountered: