Skip to content
Merged
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: 7 additions & 1 deletion plaid/requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
ALLOWED_METHODS = {'post'}
DEFAULT_TIMEOUT = 600 # 10 minutes

try:
from json.decoder import JSONDecodeError
except ImportError:
# json parsing throws a ValueError in python2
JSONDecodeError = ValueError


def _requests_http_request(url, method, data, timeout=DEFAULT_TIMEOUT):
normalized_method = method.lower()
Expand All @@ -32,7 +38,7 @@ def http_request(url, method=None, data=None, timeout=DEFAULT_TIMEOUT):
response = _requests_http_request(url, method, data or {}, timeout)
try:
response_body = json.loads(response.text)
except json.JSONDecodeError:
except JSONDecodeError:
raise PlaidError.from_response({
'error_message': response.text,
'error_type': 'API_ERROR',
Expand Down