def on_error(self, error): if isinstance(error, urllib2.URLError): code = 400 message = str(error.reason) try: code, message = error.reason[:2] except ValueError: pass error = JsonRpcProtocolError(code, message) if not isinstance(error, JsonRpcError): error = JsonRpcResponseError(data={'exception': str(error)}) error.id = self.request.id HttpRequestContext.on_error(self, error)
def __init__(self, client, request): self.client = client self.request = request data = request.dumps(encoding=self.client.encoding) HttpRequestContext.__init__(self, self.client.url, data, JsonRpcProcessor(self))