Compare commits
2 commits
f5c7e9102e
...
d2b490470f
Author | SHA1 | Date | |
---|---|---|---|
Izalia Mae | d2b490470f | ||
Izalia Mae | 5a228fce12 |
|
@ -263,8 +263,8 @@ class HttpStatus(IntEnum):
|
||||||
@property
|
@property
|
||||||
def reason(self) -> str:
|
def reason(self) -> str:
|
||||||
"The text associated with the code"
|
"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):
|
class ProtocolPort(IntEnum):
|
||||||
|
|
|
@ -144,15 +144,6 @@ class FileError(Error, metaclass = ErrorMeta):
|
||||||
class HttpError(Exception):
|
class HttpError(Exception):
|
||||||
"Error raised from a client or server response"
|
"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,
|
def __init__(self,
|
||||||
status: HttpStatus | int,
|
status: HttpStatus | int,
|
||||||
|
@ -167,8 +158,13 @@ class HttpError(Exception):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.status = HttpStatus.parse(status)
|
self.status = HttpStatus.parse(status)
|
||||||
|
"Status code and reason"
|
||||||
|
|
||||||
self.message = message or self.status.reason
|
self.message = message or self.status.reason
|
||||||
|
"Message body of the error"
|
||||||
|
|
||||||
self.headers = headers or {}
|
self.headers = headers or {}
|
||||||
|
"Headers associated with the error"
|
||||||
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
|
Loading…
Reference in a new issue