Skip to content
Myr

simplify InternalServerError.original_exception

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent eb42655 · Browse files · 2 files+5 added−22 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−22 removed

  • other:+5 added−22 removed

2 files+5 added−22 removed

modified:docs/errorhandling.rst+4 added-18 removed
247 unmodified lines
248be passed an instance of ``InternalServerError``, not the original249unhandled error.250251The original error is available as ``e.original_exception``.252Until Werkzeug 1.0.0, this attribute will only exist during unhandled253errors, use ``getattr`` to get access it for compatibility.252255.. code-block:: python253An error handler for "500 Internal Server Error" will be passed uncaught254exceptions in addition to explicit 500 errors. In debug mode, a handler255for "500 Internal Server Error" will not be used. Instead, the256interactive debugger will be shown.257257 @app.errorhandler(InternalServerError)258 def handle_500(e):259 original = getattr(e, "original_exception", None)258261 if original is None:262 # direct 500 error, such as abort(500)263 return render_template("500.html"), 500264265 # wrapped unhandled error266 return render_template("500_unhandled.html", e=original), 500267268An error handler for "500 Internal Server Error" will be passed uncaught exceptions in269addition to explicit 500 errors. In debug mode, a handler for "500 Internal Server Error" will not be used.270Instead, the interactive debugger will be shown.271272259Custom Error Pages260------------------261262Sometimes when building a Flask application, you might want to raise a
262 unmodified lines
modified:src/flask/app.py+1 added-4 removed
1445 unmodified lines
14461447 raise e14481449 self.log_exception(exc_info)1450 server_error = InternalServerError()1451 # TODO: pass as param when Werkzeug>=1.0.0 is required1452 # TODO: also remove note about this from docstring and docs1453 server_error.original_exception = e1450 server_error = InternalServerError(original_exception=e)1451 handler = self._find_error_handler(server_error)14521453 if handler is not None:1454 server_error = handler(server_error)
578 unmodified lines