Skip to content

Commit

Permalink
raise RedcapError for JSONDecodeError in get_content
Browse files Browse the repository at this point in the history
  • Loading branch information
angus-lherrou committed Apr 18, 2023
1 parent c4a6944 commit ab45bd9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions redcap/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
overload,
)

from requests import RequestException, Response, Session
from requests import RequestException, Response, Session, JSONDecodeError

if TYPE_CHECKING:
from io import TextIOWrapper
Expand Down Expand Up @@ -150,7 +150,10 @@ def get_content(
return [{}]

if format_type == "json":
return response.json()
try:
return response.json()
except JSONDecodeError as jde:
raise RedcapError("Unable to decode response as JSON") from jde

# don't do anything to csv/xml strings
return response.text
Expand Down

0 comments on commit ab45bd9

Please sign in to comment.