Skip to content
Snippets Groups Projects

F fix timeout error messages

Merged Florian Spreckelsen requested to merge f-fix-timeout-error-messages into dev
All threads resolved!
3 files
+ 49
8
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -94,12 +94,26 @@ class HTTPServerError(LinkAheadException):
"""HTTPServerError represents 5xx HTTP server errors."""
def __init__(self, body):
xml = etree.fromstring(body)
error = xml.xpath('/Response/Error')[0]
msg = error.get("description")
if error.text is not None:
msg = msg + "\n\n" + error.text
try:
# This only works if the server sends a valid XML
# response. Then it can be parsed for more information.
xml = etree.fromstring(body)
if xml.xpath('/Response/Error'):
error = xml.xpath('/Response/Error')[0]
msg = error.get("description") if error.get("description") is not None else ""
if error.text is not None:
if msg:
msg = msg + "\n\n" + error.text
else:
msg = error.text
else:
# Valid XML, but no error information
msg = body
except etree.XMLSyntaxError:
# Handling of incomplete responses, e.g., due to timeouts,
# c.f. https://gitlab.com/linkahead/linkahead-pylib/-/issues/87.
msg = body
LinkAheadException.__init__(self, msg)
Loading