twisted.python.failure.Failure class documentation
(View In Hierarchy)
A basic abstraction for an error that has occurred.
This is necessary because Python's built-in error mechanisms are inconvenient for asynchronous communication.
frame attributes contain frames.
Each frame is a tuple of (funcName, fileName, lineNumber, localsItems,
globalsItems), where localsItems and globalsItems are the contents of
globals().items() for that
frame, or an empty tuple if those details were not captured.
|The exception instance responsible for this failure.
|The exception's class.
|list of frames, innermost last, excluding
|list of frames, innermost first.
|Initialize me with an explanation of the error.
|Trap this failure if its type is in a predetermined list.
|Check if this failure's type is in a predetermined list.
|Throw the original exception into the given generator, preserving traceback information if available.
|Avoid pickling objects in the traceback.
|Remove references to other objects, replacing them with strings.
|Get an object that represents this Failure's stack that can be passed to traceback.extract_tb.
|Get a string of the exception which caused this Failure.
|Emulate Python's standard error reporting mechanism.
|Print a traceback as densely as possible.
|Print a traceback with detailed locals and globals information.
|Find the failure that represents the exception currently in context.
Initialize me with an explanation of the error.
By default, this will use the current
However, if you want to specify a particular kind of failure, you can pass
an exception as an argument.
exc_value is passed, then an "original"
Failure will be searched for. If the current exception handler
Failure is being constructed in is handling an
exception raised by
Failure will act like the original
traceback instances or
None are allowed. If
None is supplied for
exc_value, the value of
exc_tb is ignored,
None, it will be found
from execution context (ie,
|if set, capture locals and globals of stack frames. This is pretty slow,
and makes no difference unless you are going to use
Trap this failure if its type is in a predetermined list.
This allows you to trap a Failure in an error callback. It will be automatically re-raised if it is not a type that you expect.
The reason for having this particular API is because it's very useful in Deferred errback chains:
def _ebFoo(self, failure): r = failure.trap(Spam, Eggs) print 'The Failure is due to either Spam or Eggs!' if r == Spam: print 'Spam did it!' elif r == Eggs: print 'Eggs did it!'
If the failure is not a Spam or an Eggs, then the Failure will be 'passed on' to the next errback. In Python 2 the Failure will be raised; in Python 3 the underlying exception will be re-raised.
Check if this failure's type is in a predetermined list.
type, or None if no match.
Throw the original exception into the given generator, preserving traceback information if available.
|The next value yielded from the generator.
|If there are no more values in the generator.
|Anything that the generator raises.
Find the failure that represents the exception currently in context.
Avoid pickling objects in the traceback.
Remove references to other objects, replacing them with strings.
On Python 3, this will also set the
of the exception instance to
Get an object that represents this Failure's stack that can be passed to traceback.extract_tb.
If the original traceback object is still present, return that. If this
traceback object has been lost but we still have the information, return a
fake traceback object (see
If there is no traceback information at all, return None.
Get a string of the exception which caused this Failure.
Emulate Python's standard error reporting mechanism.
|If specified, a file-like object to which to write the traceback.
|A flag indicating whether to attempt to remove uninteresting frames from within Twisted itself from the output.
|A string indicating how much information to include in the traceback. Must
be one of
Print a traceback as densely as possible.
Print a traceback with detailed locals and globals information.