-
Notifications
You must be signed in to change notification settings - Fork 5
RFC: Allow for user defined exception handling in api gw handler #66
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
@heitorlessa - here is an RFC for the exception handling support for API GW. I have an example PR for it as well. |
Can we also cover the UX for handling ServiceError like the ones we provide - NotFound, etc? |
currently they would be handled for you. so we need to think of a way to not make this a breaking change. |
Currently is looks like this: except ServiceError as e:
return ResponseBuilder(...)
except Exception as exc:
handler = self._lookup_exception_handler(exc)
if handler:
return ResponseBuilder(handler(exc))
if self._debug:
return ResponseBuilder(...)
raise We could update it to be handled in except Exception as exc:
handler = self._lookup_exception_handler(exc)
if handler:
return ResponseBuilder(handler(exc))
if self._debug:
return ResponseBuilder(...)
raise Then def _lookup_exception_handler(exc):
...
if isinstanceof(ex, ServiceError):
return ResponseBuilder(
Response(...) |
Now part of 1.23.0 release. |
Key information
Summary
Allow for a simple way to define error handling
Motivation
Make it easier to define exception handling logic for api gw handlers
Proposal
If this feature should be available in other runtimes (e.g. Java, Typescript), how would this look like to ensure consistency?
User Experience
How would customers use it?
Example UX based on Fast API installing custom exception handlers
Any configuration or corner cases you'd expect?
Demonstration of before and after on how the experience will be better
Drawbacks
Make increase overall complexity.
No additional dependencies
Rationale and alternatives
Another option is to use Middleware Factor to define error handling. But this is not as intuitive.
Unresolved questions
The text was updated successfully, but these errors were encountered: