Skip to content

Commit b32847d

Browse files
committed
Revise exception handling doc on error handler functions
Document that a sync error-handler function is run in a threadpool. Extend the add_error_handler function's Pydoc. Fixes #2019
1 parent 62f8070 commit b32847d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

connexion/middleware/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ def add_error_handler(
452452
453453
:param code_or_exception: An exception class or the status code of HTTP exceptions to
454454
handle.
455-
:param function: Callable that will handle exception, may be async.
455+
:param function: Callable that will handle the exception and return a ConnexionResponse such
456+
as a `connexion.problem.problem`. May be async; a sync function is run in a threadpool.
456457
"""
457458
if self.middleware_stack is not None:
458459
raise RuntimeError(

docs/exceptions.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -115,7 +115,8 @@ You can register error handlers on:
115115

116116
.. note::
117117

118-
Error handlers can be ``async`` coroutines as well.
118+
Error handlers can be ``async`` coroutines as well. If the error handler needs to log
119+
the exception, pass the exception using the Python logger's ``exc_info`` parameter.
119120

120121
.. _Flask documentation: https://flask.palletsprojects.com/en/latest/errorhandling/#error-handlers
121122

0 commit comments

Comments
 (0)