diff --git a/plaid/errors.py b/plaid/errors.py index 7e176cae4..a2de25786 100644 --- a/plaid/errors.py +++ b/plaid/errors.py @@ -9,13 +9,16 @@ class PlaidError(Exception): safe for programmatic use. :ivar str display_message: A user-friendly error message. Not safe for programmatic use. May be None. + :ivar str request_id: A unique id returned for all server + responses. ''' - def __init__(self, message, type, code, display_message): + def __init__(self, message, type, code, display_message, request_id=""): super(PlaidError, self).__init__(message) self.type = type self.code = code self.display_message = display_message + self.request_id = request_id @staticmethod def from_response(response): @@ -28,7 +31,8 @@ def from_response(response): return cls(response['error_message'], response['error_type'], response['error_code'], - response['display_message']) + response['display_message'], + response['request_id']) class InvalidRequestError(PlaidError): diff --git a/plaid/requester.py b/plaid/requester.py index a0fbcde94..2dd195cf7 100644 --- a/plaid/requester.py +++ b/plaid/requester.py @@ -38,6 +38,7 @@ def http_request(url, method=None, data=None, timeout=DEFAULT_TIMEOUT): 'error_type': 'API_ERROR', 'error_code': 'INTERNAL_SERVER_ERROR', 'display_message': None, + 'request_id': '', }) if response_body.get('error_type'): raise PlaidError.from_response(response_body)