Skip to content

Commit 1f8ed9d

Browse files
authored
Include request_id field on PlaidError class (#119)
1 parent 6a49267 commit 1f8ed9d

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

plaid/errors.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ class PlaidError(Exception):
99
safe for programmatic use.
1010
:ivar str display_message: A user-friendly error message. Not safe
1111
for programmatic use. May be None.
12+
:ivar str request_id: A unique id returned for all server
13+
responses.
1214
'''
1315

14-
def __init__(self, message, type, code, display_message):
16+
def __init__(self, message, type, code, display_message, request_id=""):
1517
super(PlaidError, self).__init__(message)
1618
self.type = type
1719
self.code = code
1820
self.display_message = display_message
21+
self.request_id = request_id
1922

2023
@staticmethod
2124
def from_response(response):
@@ -28,7 +31,8 @@ def from_response(response):
2831
return cls(response['error_message'],
2932
response['error_type'],
3033
response['error_code'],
31-
response['display_message'])
34+
response['display_message'],
35+
response['request_id'])
3236

3337

3438
class InvalidRequestError(PlaidError):

plaid/requester.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def http_request(url, method=None, data=None, timeout=DEFAULT_TIMEOUT):
4444
'error_type': 'API_ERROR',
4545
'error_code': 'INTERNAL_SERVER_ERROR',
4646
'display_message': None,
47+
'request_id': '',
4748
})
4849
if response_body.get('error_type'):
4950
raise PlaidError.from_response(response_body)

0 commit comments

Comments
 (0)