An error containing an http response code and a possible message body
| 62 | |
| 63 | |
| 64 | class HttpError(Exception): |
| 65 | """An error containing an http response code and a possible message body""" |
| 66 | def __init__(self, code, message, body, http_headers): |
| 67 | self.code = code |
| 68 | self.message = message |
| 69 | self.body = body |
| 70 | self.http_headers = http_headers |
| 71 | |
| 72 | def __str__(self): |
| 73 | if not self.body: |
| 74 | return "HTTP code {}: {}".format(self.code, self.message) |
| 75 | else: |
| 76 | return "HTTP code {}: {} [{}]".format(self.code, self.message, self.body) |
no outgoing calls