Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise exception on HTTP errors #252

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Current (in progress)

- Nothing yet
- Raise exception on HTTP errors [#252](https://github.com/opendatateam/udata-ckan/pull/252)

## 4.0.0 (2024-06-07)

Expand Down
3 changes: 2 additions & 1 deletion udata_ckan/harvesters.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ def get_action(self, endpoint, fix=False, **kwargs):
else:
response = self.get(url, params=kwargs)

response.raise_for_status()
content_type = response.headers.get('Content-Type', '')
mime_type = content_type.split(';', 1)[0]

if mime_type == 'application/json': # Standard API JSON response
data = response.json()
# CKAN API always returns 200 even on errors
# CKAN API can returns 200 even on errors
# Only the `success` property allows to detect errors
if data.get('success', False):
return data
Expand Down