<div dir="ltr">Hi<div><br></div><div>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:</div><div><br></div><div><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">    [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] [<twisted.python.failure.Failure <class 'OpenSSL.SSL.Error'>>]</span></div><pre class="" style="margin-top:0px;margin-bottom:0px;width:1081px"><div class="" id="file-gistfile1-txt-LC3" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">    [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] Traceback (most recent call last):
</div><div class="" id="file-gistfile1-txt-LC4" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">    [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] Failure: twisted.web._newclient.ResponseNeverReceived: [<twisted.python.
</div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">failure.Failure <class 'OpenSSL.SSL.Error'>>]</div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px"><br></div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">I want to trap all such failures. I tried `failure.trap(<span style="line-height:16.7999992370605px">twisted.web._newclient.ResponseNeverReceived</span><span style="line-height:16.7999992370605px">)` but looks like that did not work. My deferred callback looks like this:</span></div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px"><span style="line-height:16.7999992370605px"><br></span></div><div class="" id="file-gistfile1-txt-LC5" style><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace"><span style="line-height:16.7999992370605px">Hi</span></font><div style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px"><br></div><div style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">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:</div><div style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px"><br></div><div style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px"><span style="line-height:16.7999992370605px">    [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] [<twisted.python.failure.Failure <class 'OpenSSL.SSL.Error'>>]</span></div><pre class="" style="margin-top:0px;margin-bottom:0px;width:1081px"><div class="" id="file-gistfile1-txt-LC3" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">    [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] Traceback (most recent call last):
</div><div class="" id="file-gistfile1-txt-LC4" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">    [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] Failure: twisted.web._newclient.ResponseNeverReceived: [<twisted.python.
</div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">failure.Failure <class 'OpenSSL.SSL.Error'>>]</div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px"><br></div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">I want to trap all such failures. I tried `failure.trap(<span style="line-height:16.7999992370605px">twisted.web._newclient.ResponseNeverReceived</span><span style="line-height:16.7999992370605px">)` but looks like that did not work. My deferred callback looks like this:</span></div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px"><span style="line-height:16.7999992370605px"><br></span></div><div class="" id="file-gistfile1-txt-LC5" style><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">    </span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace"><span style="line-height:16.7999992370605px">from twisted.internet.error import TimeoutError</span></font></div><div class="" id="file-gistfile1-txt-LC5" style><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace"><span style="line-height:16.7999992370605px">    from twisted.web._newclient import ResponseNeverReceived</span></font></div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">    def log_ignore_network_errors(failure):
        print failure.getErrorMessage()
        failure.printTraceback()
        failure.trap(TimeoutError, ResponseNeverReceived)</div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px"><br></div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">Apparently this does not catch all such errors. What am I doing wrong here?</div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px"><br></div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">Regards</div><div class="" id="file-gistfile1-txt-LC5" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px">Shakkhar</div></pre></div></pre></div>