Skip to content

Commit

Permalink
fix: Change ApiRequester to raise an exception
Browse files Browse the repository at this point in the history
Change `ApiRequester` to raise an exception for HTTP 500 responses instead of returning empty objects (#48).
  • Loading branch information
danielnsilva committed Jan 21, 2023
1 parent b2ae2bb commit c53c08c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions semanticscholar/ApiRequester.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,8 @@ def get_data(
raise ObjectNotFoundExeception(data['error'])
elif r.status_code == 429:
raise ConnectionRefusedError('HTTP status 429 Too Many Requests.')
elif r.status_code == 500:
data = r.json()
raise Exception(data['message'])

return data

0 comments on commit c53c08c

Please sign in to comment.