Permalink
Browse files

Trap connection error and raise it in errback

  • Loading branch information...
Zuhaib M Siddique
Zuhaib M Siddique committed Mar 5, 2014
1 parent 9d9261a commit 8a7634909bc2c022c627a08c548e6b06d5c36231
Showing with 5 additions and 1 deletion.
  1. +5 −1 txes/connection_http.py
View
@@ -7,7 +7,7 @@
import anyjson
-from twisted.internet import defer, reactor, protocol
+from twisted.internet import defer, reactor, protocol, error
from twisted.web import client
from twisted.web import iweb
from twisted.web import http
@@ -56,6 +56,10 @@ def execute(self, method, path, body=None, params=None):
def decode_json(body_string):
return anyjson.deserialize(body_string)
def eb(reason):
+ # Trap ConnectionRefused and raise it, no need to get status
+ e = reason.trap(error.ConnectionRefusedError)
+ if e:
+ raise error.ConnectionRefusedError, reason
status = int(reason.value.status)
try:
body = decode_json(reason.value.response)

0 comments on commit 8a76349

Please sign in to comment.