-
-
Notifications
You must be signed in to change notification settings - Fork 761
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Centralize error handling in ExceptionMiddleware (#1754)
I was writing the documentation on exception handling, and I noticed that it was very hard to explain our current behavior. Error handlers can be registered either on the internal Flask app (not the Starlette one) or on the Connexion app, which leads to some undefined (actually just really hard to explain) behavior. Eg. - Registering error handlers on a status code would capture `starlette.HTTPException` errors on the Connexion app, and `werkzeug.HTTPException` errors on the Flask App, which means that registering an error handler on a status code doesn't catch all the errors with that status code. - Flask does some default error handling which leads to some exceptions never reaching the error handlers registered on the Connexion app. So I made the following changes: - Replaced the default error handlers we registered on the Flask app with a default handler on the `ExceptionMiddleware` that takes into account other handlers registered on status codes. - Configured Flask to propagate exceptions instead of catching them. - Abstracted away the Starlette `Request` and `Response` types, so users can and must now use `ConnexionRequest` and `ConnexionResponse` types in error handlers. - Renamed the `ASGIRequest` class to `ConnexionRequest` since it is the only Request class part of the high level Connexion interface. We could also rename `ConnexionRequest` and `ConnexionResponse` to just `Request` and `Response`. Wdyt?
- Loading branch information
1 parent
1b72019
commit b9ba13c
Showing
17 changed files
with
179 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.