diff --git a/docs/errorhandling.rst b/docs/errorhandling.rst index d1b35699..764dfd20 100644 --- a/docs/errorhandling.rst +++ b/docs/errorhandling.rst @@ -249,25 +249,11 @@ be passed an instance of ``InternalServerError``, not the original unhandled error. The original error is available as ``e.original_exception``. -Until Werkzeug 1.0.0, this attribute will only exist during unhandled -errors, use ``getattr`` to get access it for compatibility. -.. code-block:: python - - @app.errorhandler(InternalServerError) - def handle_500(e): - original = getattr(e, "original_exception", None) - - if original is None: - # direct 500 error, such as abort(500) - return render_template("500.html"), 500 - - # wrapped unhandled error - return render_template("500_unhandled.html", e=original), 500 - -An error handler for "500 Internal Server Error" will be passed uncaught exceptions in -addition to explicit 500 errors. In debug mode, a handler for "500 Internal Server Error" will not be used. -Instead, the interactive debugger will be shown. +An error handler for "500 Internal Server Error" will be passed uncaught +exceptions in addition to explicit 500 errors. In debug mode, a handler +for "500 Internal Server Error" will not be used. Instead, the +interactive debugger will be shown. Custom Error Pages diff --git a/src/flask/app.py b/src/flask/app.py index d7d96cdb..e3ca8518 100644 --- a/src/flask/app.py +++ b/src/flask/app.py @@ -1447,10 +1447,7 @@ class Flask(Scaffold): raise e self.log_exception(exc_info) - server_error = InternalServerError() - # TODO: pass as param when Werkzeug>=1.0.0 is required - # TODO: also remove note about this from docstring and docs - server_error.original_exception = e + server_error = InternalServerError(original_exception=e) handler = self._find_error_handler(server_error) if handler is not None: