@@ -24,7 +24,7 @@ You can register error handlers on:
24
24
from connexion import AsyncApp
25
25
from connexion.lifecycle import ConnexionRequest, ConnexionResponse
26
26
27
- def not_found (request : ConnexionRequest, exc : Exception ) -> ConnexionResponse:
27
+ async def not_found (request : ConnexionRequest, exc : Exception ) -> ConnexionResponse:
28
28
return ConnexionResponse(status_code = 404 , body = json.dumps({" error" : " NotFound" }))
29
29
30
30
app = AsyncApp(__name__ )
@@ -45,7 +45,7 @@ You can register error handlers on:
45
45
from connexion import FlaskApp
46
46
from connexion.lifecycle import ConnexionRequest, ConnexionResponse
47
47
48
- def not_found (request : ConnexionRequest, exc : Exception ) -> ConnexionResponse:
48
+ async def not_found (request : ConnexionRequest, exc : Exception ) -> ConnexionResponse:
49
49
return ConnexionResponse(status_code = 404 , body = json.dumps({" error" : " NotFound" }))
50
50
51
51
app = FlaskApp(__name__ )
@@ -62,7 +62,7 @@ You can register error handlers on:
62
62
63
63
.. warning ::
64
64
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! **
66
66
67
67
You can also register error handlers on the underlying flask application directly.
68
68
@@ -93,7 +93,7 @@ You can register error handlers on:
93
93
from connexion import ConnexionMiddleware
94
94
from connexion.lifecycle import ConnexionRequest, ConnexionResponse
95
95
96
- def not_found (request : ConnexionRequest, exc : Exception ) -> ConnexionResponse:
96
+ async def not_found (request : ConnexionRequest, exc : Exception ) -> ConnexionResponse:
97
97
return ConnexionResponse(status_code = 404 , body = json.dumps({" error" : " NotFound" }))
98
98
99
99
app = App(__name__ )
@@ -115,7 +115,9 @@ You can register error handlers on:
115
115
116
116
.. note ::
117
117
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.
119
121
120
122
.. _Flask documentation : https://flask.palletsprojects.com/en/latest/errorhandling/#error-handlers
121
123
0 commit comments