Home » Support » Index of All Documentation » Wing IDE Reference Manual » Debugger »
10.12. Managing Exceptions
By default, Wing's debugger stops at exceptions when they would be printed by the Python interpreter. This means that any code in finally clauses, except clauses that reraise the exception, and with statement cleanup routines will be executed before the debugger stops.
The Exception Reporting preference can be used to choose different ways of reporting exceptions. The following choices are available:
When Printed (default) -- The debugger will stop on exceptions at the time that they would have been printed out by the Python interpreter.
For code with catch-all exceptions written in Python, Wing may fail to report unexpected exceptions if the handlers do not print the exception. In this case, it is best to rewrite the catch-all handlers as described in Trouble-shooting Failure to Stop on Exceptions.
Always Immediately -- The debugger will stop at every single exception immediately when it is raised. In most code this will be very often, since exceptions may be used internally to handle normal, acceptible runtime conditions. As a result, this option is usually only useful after already running close to a code that requires further examination.
At Process Termination -- In this case, the debugger will make a best effort to stop and report exceptions that actually lead to process termination. This occurs just before or sometimes just after the process is terminated. The exception is also printed to stderr, as it would be when running outside of the debugger.
When working with an Externally Launched Debug Process , the At Process Termination mode may not be able to stop the debug process before it exits, and in some cases may even fail to show any post-mortem traceback at all (except as printed to stderr in the debug process).
Similarly, when working with wxPython, PyGTK, and similar environments that include a catch-all exception handler in C/C++ code, the At Process Termination mode will fail to report any unexpected exceptions occurring during the main loop because those exceptions do not actually lead to process termination.
Immediately if Appear Unhandled -- The debugger will attempt to detect unhandled exceptions as they are raised in your debug process, making it possible to view the program state that led to the exception and to step through subsequently reached finally clauses. This is done by looking up the stack for exception handlers written in Python, and reporting only exceptions for which there is no matching handler.
The Immediately if Appear Unhandled mode works well with wxPython, PyGTK, and in most other code where unexpected exceptions either lead to program termination or are handled by catch-all exception handlers written in C/C++ extension module code.
In some cases, Wing's unhandled exception detector can report normal handled exceptions that are not seen outside of the debugger. This occurs when the exceptions are handled in C/C++ extension module code. Wing can be trained to ignore these by checking the Ignore this exception location check box in the debugger's Exception tool. Ignored exceptions are still reported if they actually lead to program termination, and your selection is remembered in your project file so only needs to be made once. Use Clear Ignored Exceptions from the Debug menu at any time to reset the ignore list to blank.
In general, we recommend using either the When Printed or the Immediately if Appear Unhandled exception reporting mode.
| « 10.11. Debugging Multi-threaded Code | Table of Contents | 10.13. Running Without Debug » |
