Package elisa :: Package core :: Package utils :: Module exception_hook

Module exception_hook

source code

Exception handler that's able to extract detailled error informations and write them to a file.

Functions
string
format_failure(failure, detail='default')
Format a failure into a human readable string (containing line-breaks).
source code
string
format_traceback(*args)
Format a traceback into a human readable string (containing line-breaks).
source code
string
write_to_logfile(data, logdir=None)
Write data to a new tempfile in the given logdir and return the path to the new file.
source code
Variables
  __maintainer__ = "Benjamin Kampmann <benjamin@fluendo.com>"

Imports: os, sys, cgitb, traceback, tempfile, StringIO


Function Details

format_failure(failure, detail='default')

source code 

Format a failure into a human readable string (containing line-breaks).

Parameters:
  • failure (twisted.internet.python.failure.Failure) - the twisted failure that should get formatted
  • detail (string) - the detail-level, proxied to twisted.internet.python.failure.Failure.printTraceback
Returns: string
the formatted traceback.

format_traceback(*args)

source code 

Format a traceback into a human readable string (containing line-breaks). If three arguments are given, they are expected to be the type of the Exceptiong, the Exception itself and the Traceback-Object (in this order). If no values are given (or the length is not 3), use sys.exc_info() to get these informations.

Returns: string
the formatted traceback.

write_to_logfile(data, logdir=None)

source code 

Write data to a new tempfile in the given logdir and return the path to the new file.

Parameters:
  • data (string or unicode) - the data to write down
  • logdir (string) - the path to the directory to log into. if None the default system temp dir is used.
Returns: string
The path to the new file or None if it didn't work