[Twisted-Python] FirstError handling from defer.gatherResults()?
daedalus at eigenmagic.com
Tue Nov 4 22:00:56 EST 2008
On Wed, 2008-11-05 at 02:51 +0100, Terry Jones wrote:
> 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)
Yes, ok. That's what I thought I should be doing, however trial appears
to still think that the error I've trapped has occurred, and ERRORs the
test. Am I not clearing state somewhere? I thought that simply handling
the failure (and not returning a Failure from the errback) would stop
Justin Warren <daedalus at eigenmagic.com>
More information about the Twisted-Python