Skip to content
Snippets Groups Projects
Commit 8883815a authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files
parent 4d6d1c86
No related branches found
No related tags found
2 merge requests!175BUG: Request responses without the "Set-Cookie" header no longer overwrite the...,!169F fix timeout error messages
Pipeline #58908 passed
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment