Skip to content
Open
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
11 changes: 10 additions & 1 deletion src/nba_api/library/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,16 @@ def get_response(self):
return self._response

def get_dict(self):
return json.loads(self._response)
try:
return json.loads(self._response)
except json.JSONDecodeError as e:
preview = (self._response or "")[:300].strip()
raise ValueError(
f"""
Failed to parse NBA API response as JSON.\n
Response preview (first 300 chars): {preview!r}
"""
) from e

def get_json(self):
return json.dumps(self.get_dict())
Expand Down