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

fix error handling in cb.py #378

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
6 changes: 4 additions & 2 deletions filip/clients/ngsi_v2/cb.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ def post_entity(
return res.headers.get("Location")
res.raise_for_status()
except requests.RequestException as err:
if err.response is None:
raise
if update and err.response.status_code == 422:
return self.override_entity(entity=entity, key_values=key_values)
if patch and err.response.status_code == 422:
Expand Down Expand Up @@ -2078,7 +2080,7 @@ def patch_entity(
except requests.RequestException as err:
# if the attribute is provided by a registration the
# deletion will fail
if not err.response.status_code == 404:
if err.response is None or not err.response.status_code == 404:
raise
else:
# Check if attributed changed in any way, if yes update
Expand All @@ -2094,7 +2096,7 @@ def patch_entity(
except requests.RequestException as err:
# if the attribute is provided by a registration the
# update will fail
if not err.response.status_code == 404:
if err.response is None or not err.response.status_code == 404:
raise

# Create new attributes
Expand Down