-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Provide in-the-box handling for page vs. API errors #2573
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
Comments
From @Tratcher on Saturday, December 23, 2017 10:03:05 AM Content-negotiation could be used rather than routing to determine the acceptable output formatting for errors. The HTML vs JSON request is related to aspnet/Diagnostics#346, but it sounds like you want something for production rather than development. Mapping exceptions to status codes is precarious. The error handling should only be used for un-expected failures which makes any built-in mapping futile. Expected errors with specific response should be handled in the APIs themselves. You may be able to at least share the logic for handling specific types of errors across APIs using MVC filters. Did you have something more specific in mind? Auth is a very different feature set from diagnostics. We're working on the redirect problem over in the Security repo with the new virtual handlers. Let's not discuss auth on this thread. |
From @breyed on Saturday, December 23, 2017 2:07:58 PM Great points. Content-negotiation is better than path for determining the format. If the MVC formatting provided a way to not only auto-format as JSON and XML, but also as HTML, it would become trivial to write an Error controller (or Razor Page) that handled all formats needed for production error reporting. Regarding exceptions, they can be just as deterministic as The nice thing about an exception-based flow is that tests for success scenarios don't need the |
From @Tratcher on Wednesday, December 27, 2017 4:15:44 AM @rynowak about auto formatting HTML vs XML/JSON. Exception based flow control is strongly discouraged and we do not design for it here. These diagnostic components are built to provide a minimal fallback experience in the event of an unexpected failure. |
From @rynowak on Wednesday, December 27, 2017 3:02:39 PM
We've had repeated requests for an experience exactly like this using JSON as the output. We haven't really dug into exactly what we'd do, but this is coming from a real place. |
Hi. Thanks for contacting us. |
From @breyed on Saturday, December 23, 2017 8:47:37 AM
Currently, a fair amount of configuration is required to report errors in a native format for pages vs. web API. It would be nice to have the following features:
Currently, I provide these features like this (and like this for redirects, but it seems like something that would be quite useful to have baked in from the start.
Copied from original issue: aspnet/Diagnostics#427
The text was updated successfully, but these errors were encountered: