[Twisted-Python] FirstError handling from defer.gatherResults()?

Terry Jones terry at jon.es
Tue Nov 4 20:51:56 EST 2008


Hi Justin

>>>>> "Justin" == Justin Warren <daedalus at eigenmagic.com> writes:
Justin> If an error occurs, gatherResults() behaves like
Justin> DeferredList(fireOnOneErrback=True), but the errback will receive a
Justin> FirstError object, not a Failure.

Justin> Normally, I'd do something like this in an Errback:

Justin> def cb_handle_failure(failure):
Justin>   e = failure.trap(MyNonFatalException)

Justin> But what is the right way to do this when I receive a FirstError?

The FirstError holds the original failure in an attribute called
subFailure. So you should be able to do

    e = failure.value.subFailure.trap(MyNonFatalException)

Terry




More information about the Twisted-Python mailing list