def __init__(self, response):
assert isinstance(response, requests.Response)
# Extended exception data attributes
self.request = response.request
"""The :class:`requests.PreparedRequest` object that initiated the API
call."""
self.response = response
"""The :class:`requests.Response` object returned from the API call."""
# Error message
response_code = response.status_code
response_reason = " " + response.reason if response.reason else ""
description = SPARK_RESPONSE_CODES.get(response_code,
"Unknown Response Code")
detail = response_to_string(response)
super(SparkApiError, self).__init__("Response Code [{}]{} - {}\n{}"
"".format(response_code,
response_reason,
description,
detail))
评论列表
文章目录