-
Notifications
You must be signed in to change notification settings - Fork 76
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
could use customisation of error presentation #39
Comments
Great point. @davepacheco and I were discussing either a ignore = true option to the endpoint annotation or having two annotations: one for APIs and one for artifacts. I could imagine we might want some different options for each. Do you have an opinion? |
See also #40. I kind of like the idea of separate |
This is needed for oxidecomputer/omicron#3333, which would do the mentioned dropshot/dropshot/src/error.rs Lines 217 to 267 in c719b41
|
To my JavaScript-pilled brain, this looks like an optional Dropshot config param that's a function with a signature like: |
I discussed a few approaches offline with @jclulow and @ahl:
The choices are basically either (1) or (2)+(3). Neither (2) nor (3) alone is enough to deal with this. (1) sounds simple but has a pretty big downside, which is that you lose a lot of information about the underlying problem. Say you're in the middle of a request handler and you have a very specific problem with a lot of information about it. With (2), you can return your own @ahl, @jclulow, and I all prefer (2) + (3). There are no immediate plans to do it, but if someone wants to address this, that looks like the way to go. (2)+(3) also completely solves #41. Consumers would be completely in control of the returned error responses so they could use the same codes, their own codes, or whatever. Edit: this approach would also solve #801, too. |
I think I might take a crack at implementing the proposed solutions (2) and (3) described in #39 (comment), since this has come up a few times recently and it would be nice to have. One thing I don't see discussed in @davepacheco's comment is how HTTP status codes for errors would be determined. The approach that comes to my mind immediately is to also require that error types implement a trait that returns an |
This is starting to look like it will also involve a reasonably big change to introduce more structured error types to dropshot's internals, in support of point (3) in the above comment from Dave:
I was hoping to be able to make those changes separately from allowing handlers to return errors other than |
One imagines many dropshot servers will be straight REST APIs, where clients are just libraries or commands and uniform JSON error messages make sense. Some, however, may also serve other artefacts; e.g., a web server that had an API component, but also an interactive HTML component that a browser may access with some pages and images and such.
Presently dropshot will produce a stock uniform JSON error response for, say, endpoints that do not map to a handler. If the client sends an
Accept
header that suggests they understand or prefer a HTML response, it'd be good to be able to choose somehow to render a reasonable 404 page or event a 302 redirect to the right place for browsers.The text was updated successfully, but these errors were encountered: