Handling libtrace errors

Exception plt_exc_libtrace

plt_libtrace_exc  is a subclass of Python's SystemError exception.  Python-libtrace checks for errors during operations on traces, see the Trace and OutputTrace page for further information.

For most purposes you can simply invoke the Trace and OutputTrace methods, knowing that if python-libtrace encounters an error it will throw a LibtraceError and exit, with the Python interpreter printing a diagnostic line to tell you what it thinks caused the problem.
Alternatively, you can catch the exception using a "try-except block," like this:

     try:
          f = plt.trace(ARGV[0])
     except:
          print "helpful message\n"
          sys.exc_clear()

Here, the sys.exc_clear() statement simply clears the exception history.

Nevil Brownlee
Mon, 30 Jun 14 (NZST)