Skip to content

Commit

Permalink
Fix crash in some kinds of addUPI telemetry errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aptiko committed Jul 31, 2023
1 parent 7f7c37d commit 7fab6c8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion enhydris/telemetry/types/addupi.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def _make_request(self, query_string):
# However, the encoding is correctly specified in the XML itself, and
# if ElementTree.fromstring() is fed the undecoded response.content,
# it reads it correctly.
return ElementTree.fromstring(response.content)
xmlroot = ElementTree.fromstring(response.content)
error = xmlroot.find("error")
if error is not None:
raise requests.RequestException(error.attrib["msg"])

Check warning on line 112 in enhydris/telemetry/types/addupi.py

View check run for this annotation

Codecov / codecov/patch

enhydris/telemetry/types/addupi.py#L112

Added line #L112 was not covered by tests
return xmlroot
except requests.RequestException as e:
raise TelemetryError(str(e))

0 comments on commit 7fab6c8

Please sign in to comment.