Fixed silly error messages that looked like 'of content-type <function parse at 0xa78e672c>'

This commit is contained in:
rdw
2008-09-03 11:50:04 -07:00
parent 9083baf1c6
commit df29d2dc47

View File

@@ -274,15 +274,16 @@ class ConnectionError(Exception):
class UnparseableResponse(ConnectionError): class UnparseableResponse(ConnectionError):
"""Raised when a loader cannot parse the response from the server.""" """Raised when a loader cannot parse the response from the server."""
def __init__(self, content_type, response, url): def __init__(self, content_type, parser, response, url):
self.content_type = content_type self.content_type = content_type
self.parser = parser
self.response = response self.response = response
self.url = url self.url = url
Exception.__init__(self) Exception.__init__(self)
def __repr__(self): def __repr__(self):
return "Could not parse the data at the URL %r of content-type %r\nData:\n%s" % ( return "Could not parse the data at the URL %r of content-type %r with %r\nData:\n%s" % (
self.url, self.content_type, self.response) self.url, self.content_type, self.parser, self.response)
__str__ = __repr__ __str__ = __repr__
@@ -562,7 +563,10 @@ class HttpSuite(object):
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except Exception, e: except Exception, e:
raise UnparseableResponse(self.loader, body, params.url) raise UnparseableResponse(response.msg.get('content-type', '(unknown)'),
self.loader,
body,
params.url)
return response.status, response.msg, body return response.status, response.msg, body