Compare commits

...

2 commits

Author SHA1 Message Date
Izalia Mae d2b490470f move HttpError property docs to __init__ 2024-04-19 22:10:31 -04:00
Izalia Mae 5a228fce12 simplify HttpStatus.reason 2024-04-19 22:09:55 -04:00
2 changed files with 7 additions and 11 deletions

View file

@ -263,8 +263,8 @@ class HttpStatus(IntEnum):
@property
def reason(self) -> str:
"The text associated with the code"
data = HTTP_REASON_REGEX.findall(self.name)
return ' '.join(data)
return " ".join(HTTP_REASON_REGEX.findall(self.name))
class ProtocolPort(IntEnum):

View file

@ -144,15 +144,6 @@ class FileError(Error, metaclass = ErrorMeta):
class HttpError(Exception):
"Error raised from a client or server response"
status: HttpStatus
"Status code and reason"
message: str
"Message body of the error"
headers: dict[str, str]
"Headers associated with the error"
def __init__(self,
status: HttpStatus | int,
@ -167,8 +158,13 @@ class HttpError(Exception):
"""
self.status = HttpStatus.parse(status)
"Status code and reason"
self.message = message or self.status.reason
"Message body of the error"
self.headers = headers or {}
"Headers associated with the error"
def __str__(self) -> str: