Skip to content

Commit

Permalink
Improve string representation of Result
Browse files Browse the repository at this point in the history
  • Loading branch information
pehala committed Nov 29, 2023
1 parent 024bbb1 commit 2481188
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions testsuite/httpx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Union

import backoff
from httpx import Client, ConnectError
from httpx import Client, ConnectError, RemoteProtocolError

from testsuite.certificates import Certificate

Expand Down Expand Up @@ -58,6 +58,11 @@ def __getattr__(self, item):
return getattr(self.response, item)
return None

def __str__(self):
if self.error is None:
return f"Result[status_code={self.response.status_code}]"
return f"Result[error={self.error}]"


class KuadrantClient(Client):
"""Httpx client which retries unstable requests"""
Expand Down Expand Up @@ -127,7 +132,7 @@ def request(
extensions=extensions,
)
return Result(self.retry_codes, response=response)
except ConnectError as e:
except (ConnectError, RemoteProtocolError) as e:
return Result(self.retry_codes, error=e)

def get(self, *args, **kwargs) -> Result:
Expand Down

0 comments on commit 2481188

Please sign in to comment.