-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Unions for response types to include errors #20
Comments
It's a little half-baked at the moment, I'm thinking a But every error has to provide a human-friendly message and machine-friendly code so it ends up being say 400 Maybe since everything is generated, you should list them in the schema and these stubs are created for you to use in your handlers. |
I was wondering if unions could be used, so rather than having some kind of dedicated error handling we could say that a method (for example a It could be generally useful for more complex methods too. |
That could work, I'll give it some thought, in Go-land at least it would be more idiomatic to return |
I would have thought an error from the library would be that the transport failed, rather than it being a business logic error. It is tricky to draw the lines though. One thing about using Go's error mechanism for all error cases is that it's no longer possible to return multiple errors, so people using this to drive a UI wouldn't be able to show all the validation problems to the user without rolling their own secondary error handling. |
True true, I did want to support arbitrary error context, just some object or whatever you want along-side |
In Go would having an interface with the members documented be sufficient? I'm not sure how common it is to downcast from an interface |
It's totally doable in Go, but definitely not idiomatic, you pretty much never see a single interface value returned which acts as a union for errors as well. Maybe that will change once generics are introduced, but returning Maybe we can still treat errors in the schema as regular types, but have methods provide |
A success union and an error union could map well onto Go, languages with exceptions, and languages with a Result type. :) Would network errors get automatically merged into the error union? |
Hmm I guess worst-case this package could just have an implicit type for network errors. I'll probably worry more about error handling in a month or two to polish this stuff up |
Hello!
Very interested in this library! Looks very useful.
I'm interested in how you approach error handling with this library, but could not find any examples or docs.
Examples of errors might be resource not found for a given id, user not authenticated, user not authorized, etc.
Thanks,
Louis
The text was updated successfully, but these errors were encountered: