Hi Mashiat,

> On May 12, 2015, at 9:53 AM, Mashiat Sarker Shakkhar 
> <mashiat.sar...@gmail.com> wrote:
> 
> Hi
> 
> If I want to trap a certain type of exception in a deferred call, how do I 
> specify it? For example, I see a failure like this:
> 
>     [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] 
> [<twisted.python.failure.Failure <class 'OpenSSL.SSL.Error'>>]
>     [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] Traceback (most 
> recent call last):
>     [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] Failure: 
> twisted.web._newclient.ResponseNeverReceived: [<twisted.python.
> failure.Failure <class 'OpenSSL.SSL.Error'>>]
> 
> I want to trap all such failures. I tried 
> `failure.trap(twisted.web._newclient.ResponseNeverReceived)` but looks like 
> that did not work. My deferred callback looks like this:
> 
>     from twisted.internet.error import TimeoutError
>     from twisted.web._newclient import ResponseNeverReceived
>     def log_ignore_network_errors(failure):
>         print failure.getErrorMessage()
>         failure.printTraceback()
>         failure.trap(TimeoutError, ResponseNeverReceived)
> 
> Apparently this does not catch all such errors. What am I doing wrong here?
> 
This code sample does not indicate that you have actually assigned 
log_ignore_network_errors as an errback on a Deferred anywhere.  If you can 
provide a working code example that demonstrates your issue, it will be easier 
to help you :)

L. Daniel Burr

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to