@@ -24,7 +24,7 @@ You can register error handlers on:
2424 from connexion import AsyncApp
2525 from connexion.lifecycle import ConnexionRequest, ConnexionResponse
2626
27- def not_found (request : ConnexionRequest, exc : Exception ) -> ConnexionResponse:
27+ async def not_found (request : ConnexionRequest, exc : Exception ) -> ConnexionResponse:
2828 return ConnexionResponse(status_code = 404 , body = json.dumps({" error" : " NotFound" }))
2929
3030 app = AsyncApp(__name__ )
@@ -45,7 +45,7 @@ You can register error handlers on:
4545 from connexion import FlaskApp
4646 from connexion.lifecycle import ConnexionRequest, ConnexionResponse
4747
48- def not_found (request : ConnexionRequest, exc : Exception ) -> ConnexionResponse:
48+ async def not_found (request : ConnexionRequest, exc : Exception ) -> ConnexionResponse:
4949 return ConnexionResponse(status_code = 404 , body = json.dumps({" error" : " NotFound" }))
5050
5151 app = FlaskApp(__name__ )
@@ -62,7 +62,7 @@ You can register error handlers on:
6262
6363 .. warning ::
6464
65- ⚠️ **The following is not recommended as it complicates the exception handling logic, **
65+ ⚠️ **The following is not recommended as it complicates the exception handling logic! **
6666
6767 You can also register error handlers on the underlying flask application directly.
6868
@@ -93,7 +93,7 @@ You can register error handlers on:
9393 from connexion import ConnexionMiddleware
9494 from connexion.lifecycle import ConnexionRequest, ConnexionResponse
9595
96- def not_found (request : ConnexionRequest, exc : Exception ) -> ConnexionResponse:
96+ async def not_found (request : ConnexionRequest, exc : Exception ) -> ConnexionResponse:
9797 return ConnexionResponse(status_code = 404 , body = json.dumps({" error" : " NotFound" }))
9898
9999 app = App(__name__ )
@@ -115,7 +115,9 @@ You can register error handlers on:
115115
116116.. note ::
117117
118- Error handlers can be ``async `` coroutines as well.
118+ Connexion error handlers are not required to be ``async `` coroutines. However, the
119+ middleware must wrap a regular function to call it, and a wrapped handler function
120+ has no access to the stack traceback from the exception.
119121
120122.. _Flask documentation : https://flask.palletsprojects.com/en/latest/errorhandling/#error-handlers
121123
0 commit comments