Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions plaid/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
1 change: 1 addition & 0 deletions plaid/requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down