# Module e.c.u.exception_hook

Part of elisa.core.utils

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

Line # | Kind | Name | Docs
--- | --- | --- | ---
28 | Function | format_failure | Format a failure into a human readable string (containing line-breaks).
46 | Function | format_traceback | Format a traceback into a human readable string (containing line-breaks).
68 | Function | write_to_logfile | Write data to a new tempfile in the given logdir and return the path to

def format_failure(failure, detail='default'):
Format a failure into a human readable string (containing line-breaks).

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

def format_traceback(*args):
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 | the formatted traceback. (type: string )

def write_to_logfile(data, logdir=None):
Write data to a new tempfile in the given logdir and return the path to the new file.

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