Skip to content
Myr

normalize sentence spacing

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 569c88d · Browse files · 1 file+19 added−19 removed
This commit

State

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

Diff stats

1 file+19 added−19 removed

  • other:+19 added−19 removed

1 file+19 added−19 removed

modified:docs/errorhandling.rst+19 added-19 removed
1 unmodified line
2===========================34.. versionadded:: 0.356Applications fail, servers fail. Sooner or later you will see an exception7in production. Even if your code is 100% correct, you will still see8exceptions from time to time. Why? Because everything else involved will9fail. Here are some situations where perfectly fine code can lead to server6Applications fail, servers fail. Sooner or later you will see an exception7in production. Even if your code is 100% correct, you will still see8exceptions from time to time. Why? Because everything else involved will9fail. Here are some situations where perfectly fine code can lead to server10errors:1112- the client terminated the request early and the application was still13 reading from the incoming data
3 unmodified lines
17- a backend server overloaded18- a programming error in a library you are using19- network connection of the server to another system failed2021And that's just a small sample of issues you could be facing. So how do we22deal with that sort of problem? By default if your application runs in21And that's just a small sample of issues you could be facing. So how do we22deal with that sort of problem? By default if your application runs in23production mode, and an exception is raised Flask will display a very simple24page for you and log the exception to the :attr:`~flask.Flask.logger`.2526But there is more you can do, and we will cover some better setups to deal
11 unmodified lines
38 syntax, missing query parameters, etc.3940*403 Forbidden*41 If you have some kind of access control on your website, you will have42 to send a 403 code for disallowed resources. So make sure the user42 to send a 403 code for disallowed resources. So make sure the user43 is not lost when they try to access a forbidden resource.4445*404 Not Found*46 The good old "chap, you made a mistake typing that URL" message. So46 The good old "chap, you made a mistake typing that URL" message. So47 common that even novices to the internet know that 404 means: damn,48 the thing I was looking for is not there. It's a very good idea to48 the thing I was looking for is not there. It's a very good idea to49 make sure there is actually something useful on a 404 page, at least a50 link back to the index.5152*410 Gone*53 Did you know that there the "404 Not Found" has a brother named "41054 Gone"? Few people actually implement that, but the idea is that54 Gone"? Few people actually implement that, but the idea is that55 resources that previously existed and got deleted answer with 41056 instead of 404. If you are not deleting documents permanently from56 instead of 404. If you are not deleting documents permanently from57 the database but just mark them as deleted, do the user a favour and58 use the 410 code instead and display a message that what they were59 looking for was deleted for all eternity.60
7 unmodified lines
6869Sending error mails, even if just for critical ones, can become70overwhelming if enough users are hitting the error and log files are71typically never looked at. This is why we recommend using `Sentry72<https://sentry.io/>`_ for dealing with application errors. It's72<https://sentry.io/>`_ for dealing with application errors. It's73available as an Open Source project `on GitHub74<https://github.com/getsentry/sentry>`_ and is also available as a `hosted version75<https://sentry.io/signup/>`_ which you can try for free. Sentry76aggregates duplicate errors, captures the full stack trace and local
20 unmodified lines
9798Follow-up reads:99100* Sentry also supports catching errors from your worker queue (RQ, Celery) in a101 similar fashion. See the `Python SDK docs101 similar fashion. See the `Python SDK docs102 <https://docs.sentry.io/platforms/python/>`_ for more information.103* `Getting started with Sentry <https://docs.sentry.io/quickstart/?platform=python>`_104* `Flask-specific documentation <https://docs.sentry.io/platforms/python/flask/>`_.105
315 unmodified lines
421Blueprint Error Handling422````````````````````````423424In blueprints, error handlers will work as expected. However, there is a caveat425concerning handlers for 404 and 405 exceptions. These error handlers are only425concerning handlers for 404 and 405 exceptions. These error handlers are only426invoked from an appropriate ``raise`` statement or a call to ``abort`` in another427of the blueprint's view functions; they are not invoked by, e.g., an invalid URL428access.429
128 unmodified lines
558559When in Doubt, Run Manually560---------------------------561562Having problems getting your application configured for production? If you562Having problems getting your application configured for production? If you563have shell access to your host, verify that you can run your application564manually from the shell in the deployment environment. Be sure to run under564manually from the shell in the deployment environment. Be sure to run under565the same user account as the configured deployment to troubleshoot permission566issues. You can use Flask's builtin development server with `debug=True` on566issues. You can use Flask's builtin development server with `debug=True` on567your production host, which is helpful in catching configuration issues, but568**be sure to do this temporarily in a controlled environment.** Do not run in569production with `debug=True`.570
3 unmodified lines
574Working with Debuggers575----------------------576577To dig deeper, possibly to trace code execution, Flask provides a debugger out578of the box (see :ref:`debug-mode`). If you would like to use another Python579debugger, note that debuggers interfere with each other. You have to set some578of the box (see :ref:`debug-mode`). If you would like to use another Python579debugger, note that debuggers interfere with each other. You have to set some580options in order to use your favorite debugger:581582* ``debug`` - whether to enable debug mode and catch exceptions583* ``use_debugger`` - whether to use the internal Flask debugger
26 unmodified lines