From 63a126c66a047507f634348688dfcf760b14d5ae Mon Sep 17 00:00:00 2001 From: Jamie Grove Date: Sat, 10 Aug 2013 11:35:47 -0400 Subject: [PATCH] Update blueprints.rst - Error Handlers Added information about custom error handlers in Blueprints with example based simple_page. --- docs/blueprints.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/blueprints.rst b/docs/blueprints.rst index 4e3888c2..8f83e120 100644 --- a/docs/blueprints.rst +++ b/docs/blueprints.rst @@ -202,3 +202,18 @@ you can use relative redirects by prefixing the endpoint with a dot only:: This will link to ``admin.index`` for instance in case the current request was dispatched to any other admin blueprint endpoint. + +Error Handlers +-------------- + +Blueprints support the errorhandler decorator just like the :class:`Flask` +application object, so it is easy to make Blueprint-specific custom error +pages. + +Here is an example for a "404 Page Not Found" exception:: + + @simple_page.errorhandler(404) + def page_not_found(e): + return render_template('pages/404.html') + +More information on error handling see :ref:`errorpages`.