fandango.excepts module¶
Contents
Classes¶
ExceptionManager¶
- class fandango.excepts.ExceptionManager(logger=<fandango.log.Logger object at 0x7eff577e7d50>, origin=None, postmethod=None, verbose=True, rethrow=True)[source]¶
This was a version of ExceptionWrapper to be used as ContextManager together with with statement. Not really tested nor used, just a proof of concept.
Functions¶
ExceptionWrapper¶
- fandango.excepts.ExceptionWrapper(fun, logger=<fandango.log.Logger object at 0x7eff577e7d50>, postmethod=None, showArgs=False, verbose=True, rethrow=False, default=None)[source]¶
Implementation of the popular Catched() decorator:
- it will execute your method within a a try/except
- it will print the traceback
- if :rethrow: is False it will return :default: in case of exception
Example: @ExceptionWrapper def funny():
print ‘what?’ endfunny()
Catched¶
- fandango.excepts.Catched(fun, logger=<fandango.log.Logger object at 0x7eff577e7d50>, postmethod=None, showArgs=False, verbose=True, rethrow=False, default=None)¶
Implementation of the popular Catched() decorator:
- it will execute your method within a a try/except
- it will print the traceback
- if :rethrow: is False it will return :default: in case of exception
Example: @ExceptionWrapper def funny():
print ‘what?’ endfunny()
trial¶
- fandango.excepts.trial(tries, excepts=None, args=None, kwargs=None, return_exception=None)[source]¶
This method executes a try,except clause in a single line :param tries: may be a callable or a list of callables :param excepts: it can be a callable, a list of callables, a map of {ExceptionType:[callables]} or just a default value to return :param args,kwargs: arguments to be passed to the callable :return exception: whether to return exception or None (default)
raw autodoc¶
- fandango.excepts.Catched(fun, logger=<fandango.log.Logger object at 0x7eff577e7d50>, postmethod=None, showArgs=False, verbose=True, rethrow=False, default=None)
Implementation of the popular Catched() decorator:
- it will execute your method within a a try/except
- it will print the traceback
- if :rethrow: is False it will return :default: in case of exception
Example: @ExceptionWrapper def funny():
print ‘what?’ endfunny()
- class fandango.excepts.ExceptionManager(logger=<fandango.log.Logger object at 0x7eff577e7d50>, origin=None, postmethod=None, verbose=True, rethrow=True)[source]
Bases: object
This was a version of ExceptionWrapper to be used as ContextManager together with with statement. Not really tested nor used, just a proof of concept.
- fandango.excepts.ExceptionWrapper(fun, logger=<fandango.log.Logger object at 0x7eff577e7d50>, postmethod=None, showArgs=False, verbose=True, rethrow=False, default=None)[source]
Implementation of the popular Catched() decorator:
- it will execute your method within a a try/except
- it will print the traceback
- if :rethrow: is False it will return :default: in case of exception
Example: @ExceptionWrapper def funny():
print ‘what?’ endfunny()
- exception fandango.excepts.RethrownException[source]
Bases: exceptions.Exception
- fandango.excepts.exc2str(e)[source]
- fandango.excepts.getLastException()[source]
returns last exception traceback
- fandango.excepts.getPreviousExceptions(limit=0)[source]
sys.exc_info() returns : type,value,traceback traceback.extract_tb(traceback) : returns (filename, line number, function name, text)
- fandango.excepts.trial(tries, excepts=None, args=None, kwargs=None, return_exception=None)[source]
This method executes a try,except clause in a single line :param tries: may be a callable or a list of callables :param excepts: it can be a callable, a list of callables, a map of {ExceptionType:[callables]} or just a default value to return :param args,kwargs: arguments to be passed to the callable :return exception: whether to return exception or None (default)