From e34ce5063569c5be79f42a2b9815755f71553311 Mon Sep 17 00:00:00 2001 From: Joy Zheng Date: Thu, 12 Apr 2018 12:00:37 -0700 Subject: [PATCH 1/2] Include request_id field on PlaidError class --- plaid/errors.py | 8 ++++++-- plaid/requester.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plaid/errors.py b/plaid/errors.py index 7e176cae4..d5d411ad8 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) From 402232eb680a4181937dbe811c78cdb07a483b84 Mon Sep 17 00:00:00 2001 From: Joy Zheng Date: Mon, 16 Apr 2018 09:13:25 -0700 Subject: [PATCH 2/2] make request_id an optional param --- plaid/errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plaid/errors.py b/plaid/errors.py index d5d411ad8..a2de25786 100644 --- a/plaid/errors.py +++ b/plaid/errors.py @@ -13,7 +13,7 @@ class PlaidError(Exception): responses. ''' - def __init__(self, message, type, code, display_message, request_id): + def __init__(self, message, type, code, display_message, request_id=""): super(PlaidError, self).__init__(message) self.type = type self.code = code