rewrite external debuggers section
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 0db9525 · Browse files · 1 file·+23 added−27 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+23 added−27 removed
- other:+23 added−27 removed
Provenance
- Commit
2db3c9a- Tree
c488521- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
0db9525
1 file changed+23 added−27 removed
modified:docs/errorhandling.rst+23 added-27 removed
1 Handling Application Errors2 ===========================3 4-.. versionadded:: 0.35-4 Applications fail, servers fail. Sooner or later you will see an exception5 in production. Even if your code is 100% correct, you will still see6 exceptions from time to time. Why? Because everything else involved will7 fail. Here are some situations where perfectly fine code can lead to server563 unmodified lines571 572 Working with Debuggers573 ----------------------574 577-To dig deeper, possibly to trace code execution, Flask provides a debugger out578-of the box (see :ref:`debug-mode`). If you would like to use another Python579-debugger, note that debuggers interfere with each other. You have to set some580-options in order to use your favorite debugger:575+The built-in development server provides a :ref:`debug-mode` that shows576+an interactive traceback in the browser when an unhandled error occurs577+during a request.578 582-* ``debug`` - whether to enable debug mode and catch exceptions583-* ``use_debugger`` - whether to use the internal Flask debugger584-* ``use_reloader`` - whether to reload and fork the process if modules585- were changed579+External debuggers, such as those provided by IDEs, can offer a much580+more powerful and visual debugging experience. They can also be used to581+step through code during a request before an error is raised, or if no582+error is raised.583 587-``debug`` must be True (i.e., exceptions must be caught) in order for the other588-two options to have any value.584+When using an external debugger, the app should still be in debug mode,585+but it can be useful to disable the built-in debugger and reloader,586+which can interfere.587 590-If you're using Aptana/Eclipse for debugging you'll need to set both591-``use_debugger`` and ``use_reloader`` to False.588+When running from the command line:589 593-A possible useful pattern for configuration is to set the following in your594-config.yaml (change the block as appropriate for your application, of course)::590+.. code-block:: text591 596- FLASK:597- DEBUG: True598- DEBUG_WITH_APTANA: True592+ $ export FLASK_ENV=development593+ $ flask run --no-debugger --no-reload594 600-Then in your application's entry-point (main.py),601-you could have something like::595+When running from Python:596 603- if __name__ == "__main__":604- # To allow aptana to receive errors, set use_debugger=False605- app = create_app(config="config.yaml")597+.. code-block:: python598 607- use_debugger = app.debug and not(app.config.get('DEBUG_WITH_APTANA'))608- app.run(use_debugger=use_debugger, debug=app.debug,609- use_reloader=use_debugger, host='0.0.0.0')599+ app.run(debug=True, use_debugger=False, use_reloader=False)600+601+Disabling these isn't required, an external debugger will continue to602+work with the following caveats. If the built-in debugger is not603+disabled, it will catch unhandled exceptions before the external604+debugger can. If the reloader is not disabled, it could cause an605+unexpected reload if code changes during debugging.