| 101 | |
| 102 | |
| 103 | class ApiException(OpenApiException): |
| 104 | |
| 105 | def __init__(self, status=None, reason=None, http_resp=None): |
| 106 | if http_resp: |
| 107 | self.status = http_resp.status |
| 108 | self.reason = http_resp.reason |
| 109 | self.body = http_resp.data |
| 110 | self.headers = http_resp.getheaders() |
| 111 | else: |
| 112 | self.status = status |
| 113 | self.reason = reason |
| 114 | self.body = None |
| 115 | self.headers = None |
| 116 | |
| 117 | def __str__(self): |
| 118 | """Custom error messages for exception""" |
| 119 | error_message = "({0})\n"\ |
| 120 | "Reason: {1}\n".format(self.status, self.reason) |
| 121 | if self.headers: |
| 122 | error_message += "HTTP response headers: {0}\n".format( |
| 123 | self.headers) |
| 124 | |
| 125 | if self.body: |
| 126 | error_message += "HTTP response body: {0}\n".format(self.body) |
| 127 | |
| 128 | return error_message |
| 129 | |
| 130 | |
| 131 | class NotFoundException(ApiException): |
no outgoing calls