Skip to content
Snippets Groups Projects

F fix timeout error messages

Merged Florian Spreckelsen requested to merge f-fix-timeout-error-messages into dev
3 files
+ 49
8
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -94,12 +94,26 @@ class HTTPServerError(LinkAheadException):
@@ -94,12 +94,26 @@ class HTTPServerError(LinkAheadException):
"""HTTPServerError represents 5xx HTTP server errors."""
"""HTTPServerError represents 5xx HTTP server errors."""
def __init__(self, body):
def __init__(self, body):
xml = etree.fromstring(body)
try:
error = xml.xpath('/Response/Error')[0]
# This only works if the server sends a valid XML
msg = error.get("description")
# response. Then it can be parsed for more information.
xml = etree.fromstring(body)
if error.text is not None:
if xml.xpath('/Response/Error'):
msg = msg + "\n\n" + error.text
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)
LinkAheadException.__init__(self, msg)
Loading