mirror of https://github.com/searxng/searxng.git
[fix] error recorder: avoid RuntimeError on some rare occasion
httpx.RequestError (subclass of httpx.HTTPError) has a property request. This property raises a RuntimeError if the attributes _request is None. To avoid a cascade of errors, this commit reads directly the _request attribute.
This commit is contained in:
parent
b10403d3a1
commit
41f6359d06
|
@ -74,9 +74,11 @@ def get_request_exception_messages(exc: HTTPError)\
|
||||||
status_code = None
|
status_code = None
|
||||||
reason = None
|
reason = None
|
||||||
hostname = None
|
hostname = None
|
||||||
if hasattr(exc, 'request') and exc.request is not None:
|
if hasattr(exc, '_request') and exc._request is not None:
|
||||||
|
# exc.request is property that raise an RuntimeException
|
||||||
|
# if exc._request is not defined.
|
||||||
url = exc.request.url
|
url = exc.request.url
|
||||||
if url is None and hasattr(exc, 'response') and exc.respones is not None:
|
if url is None and hasattr(exc, 'response') and exc.response is not None:
|
||||||
url = exc.response.url
|
url = exc.response.url
|
||||||
if url is not None:
|
if url is not None:
|
||||||
hostname = url.host
|
hostname = url.host
|
||||||
|
|
Loading…
Reference in New Issue