Failure to Stop on Exceptions


Home » Support » Index of All Documentation » Wing IDE Reference Manual » Trouble-shooting Guide » Trouble-shooting Failure to Debug »

Failure to stop on exceptions is most commonly caused by the same factors that can cause failure to stop on breakpoints. The rest of this section covers additional possible causes of failure to stop on exceptions.

By default, Wing only stops on exceptions for which a traceback is printed when the code is run outside of the debugger. If your code runs within a catch-all try/except clause written in Python (as in some GUI main loops or in an environment like Zope), Wing may not report all exceptions encountered in your debug process.

In some cases, altering the Exception Reporting preference will work. In others, it may suffice to set a breakpoint in the top-level exception handler.

An alternative is to recode your app by adding the following code to catch-all exception handlers:

import os, sys
if 'WINGDB_ACTIVE' in os.environ:
  sys.excepthook(*sys.exc_info())

The above only works with the default exception handling configuration. If you are not using the When Printed exception handling mode (as set by the Report Exceptions preference) then the above will not cause the debugger to stop. In that case, the following variant can be used instead:

import os

# No handler when running in Wing's debugger
if 'WINGDB_ACTIVE' in os.environ:
  dosomething()

# Handle unexpected exceptions gracefully at other times
else:
  try:
    dosomething()
  except:
    # handler here

Note that environments such as wxPython, PyGTK, and others include catch-all handlers for unexpected exceptions raised in the main loop, but those handlers cause the exception traceback to be printed and thus will be reported correctly by Wing without any modification to the handler.

« 18.2.1. Failure to Stop on Breakpoints or Show Source CodeTable of Contents18.2.3. Extra Debugger Exceptions »