Skip to content

Commit

Permalink
Merge pull request #1855 from locustio/HttpUser-unpack-known-exceptions
Browse files Browse the repository at this point in the history
HttpUser: Unpack known exceptions
  • Loading branch information
cyberw authored Aug 19, 2021
2 parents d7efc71 + 0f621c9 commit 88b61f7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions locust/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ def request(self, method, url, name=None, catch_response=False, context={}, **kw
try:
response.raise_for_status()
except RequestException as e:
while (
isinstance(
e,
(
requests.exceptions.ConnectionError,
requests.packages.urllib3.exceptions.ProtocolError,
requests.packages.urllib3.exceptions.MaxRetryError,
requests.packages.urllib3.exceptions.NewConnectionError,
),
)
and e.__context__ # Not sure if the above exceptions can ever be the lowest level, but it is good to be sure
):
e = e.__context__
request_meta["exception"] = e

self.request_event.fire(**request_meta)
Expand Down

0 comments on commit 88b61f7

Please sign in to comment.