Source code for worldline.connect.sdk.communication.response_exception
from response_header import get_header_value, get_header
[docs]class ResponseException(RuntimeError):
"""
Thrown when a response was received from the Worldline Global Collect platform which indicates an error.
"""
def __init__(self, status, body, headers):
super(ResponseException, self).__init__("the Worldline Global Collect platform returned an error response")
self.__status_code = status
self.__headers = headers if headers is not None else {}
self.__body = body
@property
def status_code(self):
"""
:return: The HTTP status code that was returned by the Worldline Global Collect platform.
"""
return self.__status_code
@property
def body(self):
"""
:return: The raw response body that was returned by the Worldline Global Collect platform.
"""
return self.__body
@property
def headers(self):
"""
:return: The headers that were returned by the Worldline Global Collect platform. Never None.
"""
return self.__headers
def __str__(self):
string = super(ResponseException, self).__str__()
status_code = self.__status_code
if status_code > 0:
string += "; status_code=" + str(status_code)
response_body = self.__body
if response_body:
string += "; response_body='" + response_body + "'"
return str(string)