Skip to content

Commit 68aa210

Browse files
authored
Merge pull request #378 from paul-l1/377-fix-error-handling-in-ContextBrokerClient
fix error handling in cb.py
2 parents 597abb5 + 2af1166 commit 68aa210

File tree

1 file changed

+4
-2
lines changed
  • filip/clients/ngsi_v2

1 file changed

+4
-2
lines changed

Diff for: filip/clients/ngsi_v2/cb.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ def post_entity(
261261
return res.headers.get("Location")
262262
res.raise_for_status()
263263
except requests.RequestException as err:
264+
if err.response is None:
265+
raise
264266
if update and err.response.status_code == 422:
265267
return self.override_entity(entity=entity, key_values=key_values)
266268
if patch and err.response.status_code == 422:
@@ -2078,7 +2080,7 @@ def patch_entity(
20782080
except requests.RequestException as err:
20792081
# if the attribute is provided by a registration the
20802082
# deletion will fail
2081-
if not err.response.status_code == 404:
2083+
if err.response is None or not err.response.status_code == 404:
20822084
raise
20832085
else:
20842086
# Check if attributed changed in any way, if yes update
@@ -2094,7 +2096,7 @@ def patch_entity(
20942096
except requests.RequestException as err:
20952097
# if the attribute is provided by a registration the
20962098
# update will fail
2097-
if not err.response.status_code == 404:
2099+
if err.response is None or not err.response.status_code == 404:
20982100
raise
20992101

21002102
# Create new attributes

0 commit comments

Comments
 (0)