Skip to content
Myr

Added documentation in update document for new error handling

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

authored by Armin Ronacher · committed by Armin Ronacher · parent f5ec995 · Browse files · 2 files+36 added−0 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+36 added−0 removed

  • other:+36 added−0 removed

2 files+36 added−0 removed

modified:docs/upgrading.rst+27 added
89 unmodified lines
90 # g.db is still bound if there is such a thing9192 # and here it's gone9394Manual Error Handler Attaching95``````````````````````````````9697While it is still possible to attach error handlers to98:attr:`Flask.error_handlers` it's discouraged to do so and in fact99deprecated. In generaly we no longer recommend custom error handler100attaching via assignments to the underlying dictionary due to the more101complex internal handling to support arbitrary exception classes and102blueprints. See :meth:`Flask.errorhandler` for more information.103104The proper upgrade is to change this::105106 app.error_handlers[403] = handle_error107108Into this::109110 app.register_error_handler(403, handle_error)111112Alternatively you should just attach the function with a decorator::113114 @app.errorhandler(403)115 def handle_error(e):116 ...117118(Note that :meth:`register_error_handler` is new in Flask 0.7)119120121Version 0.6122-----------123124Flask 0.6 comes with a backwards incompatible change which affects the
87 unmodified lines
modified:flask/app.py+9 added
820 unmodified lines
821 self._register_error_handler(None, code_or_exception, f)822 return f823 return decorator824825 def register_error_handler(self, code_or_exception, f):826 """Alternative error attach function to the :meth:`errorhandler`827 decorator that is more straightforward to use for non decorator828 usage.829830 .. versionadded:: 0.7831 """832 self._register_error_handler(None, code_or_exception, f)833834 def _register_error_handler(self, key, code_or_exception, f):835 if isinstance(code_or_exception, HTTPException):836 code_or_exception = code_or_exception.code837 if isinstance(code_or_exception, (int, long)):
445 unmodified lines