-
Notifications
You must be signed in to change notification settings - Fork 5
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
Result handling #73
Comments
Thanks for the idea! I've felt that there could be an improvement to the error handling model in Qubit but I haven't quite been able to work out what feels good. Up until this point, I've been taking inspiration from both Axum and jsonrpsee's handlers. In both of these libraries, they don't really do anything super special with errors outside of what their underlying protocols (HTTP/JSONRPC) supply. For example, Axum doesn't really care what you do as long as you return a status code/headers/response/etc. jsonrpsee will allow a I do like the idea of upgrading the handlers to return like so:
There are also some other potential ways of achieving this without introducing special behaviour for results into Qubit: Create an application error using anyhow/thiserror/enums, which should contain all appropriate user-facing error messages (friendly, no sensitive information), and handle the transformation from internal error types (eg DB errors). Have your handlers return Using client plugins (currently quite new and undocumented, but they provide a way to add additional commands to your chain), add an unwrap method which could look like this: api.read_posts.unwrapQuery() This unwrap method can query the API as normal, but perform your unwrapping logic. Given that the plugin definition is correct, the type of the I hope these options make sense, I'm interested in your opinion on the two, or if you've got any other ideas on how to implement this. |
Perfect. For me There should also be a And on the client there would be no changes, since the I have worked with other frameworks (eg: https://www.meteor.com/) where this is standard behavior and I found it very intuitive, and I replicate this with my RPC framework things too. Structured errors or more complex handling would be out-of-scope. |
I would like if qubit handled
Results
for me.I'm using a database for the queries and every operation returns a Result.
I would like if qubit:
For now I'm using a custom result type:
Usage:
And an unwrap function in TS
Thanks!
The text was updated successfully, but these errors were encountered: