Exceptions¶
All library exceptions derive from
MregApiBaseError.
HTTP response status errors (ResponseError and subclasses) compose the original HTTP response and expose parsed error details for errors that derive from the server's drf-standardized-errors errors.
exceptions
¶
Exception classes for MREG API errors.
APIError
¶
Bases: ResponseError
Deprecated alias for ResponseError.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
BadRequestError
¶
Bases: ClientError
HTTP 400 Bad Request.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
CacheError
¶
CacheMiss
¶
ClientError
¶
Bases: HTTPStatusError
HTTP 4xx client error.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
ConflictError
¶
Bases: ClientError
HTTP 409 Conflict.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
ConnectionFailedError
¶
EntityAlreadyExists
¶
EntityConflictError
¶
Bases: EntityError
A mutating operation's precondition on entity state was not met.
Either the entity already existed when it was expected to be absent, or a required relation between entities was absent.
__init__
¶
EntityError
¶
Bases: MregApiBaseError
A request succeeded but the result or state was not as required.
Never stems from an HTTP response failure; always indicates a problem with the entity state after successfully completing the request.
__init__
¶
EntityLookupError
¶
EntityNotFound
¶
EntityOwnershipMismatch
¶
EntityRelationMissing
¶
Bases: EntityConflictError
A required relation between two entities is absent (e.g. role lacks a label).
__init__
¶
ForbiddenError
¶
Bases: ClientError
HTTP 403 Forbidden.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
ForceMissing
¶
HTTPStatusError
¶
Bases: ResponseError
Server returned a 4xx or 5xx status code.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
IPNetworkError
¶
InputFailure
¶
InternalError
¶
InvalidAuthTokenError
¶
Bases: UnauthorizedError
Invalid authentication token.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
InvalidIPAddress
¶
InvalidIPv4Address
¶
InvalidIPv4Network
¶
InvalidIPv6Address
¶
InvalidIPv6Network
¶
InvalidNetwork
¶
LoginFailedError
¶
Bases: UnauthorizedError
Login failed.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
MREGError
pydantic-model
¶
Bases: BaseModel
Details of an MREG error.
Show JSON schema:
{
"description": "Details of an MREG error.",
"properties": {
"code": {
"title": "Code",
"type": "string"
},
"detail": {
"title": "Detail",
"type": "string"
},
"attr": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Attr"
}
},
"required": [
"code",
"detail",
"attr"
],
"title": "MREGError",
"type": "object"
}
Fields:
MREGErrorResponse
pydantic-model
¶
Bases: BaseModel
MREG error response.
Show JSON schema:
{
"$defs": {
"MREGError": {
"description": "Details of an MREG error.",
"properties": {
"code": {
"title": "Code",
"type": "string"
},
"detail": {
"title": "Detail",
"type": "string"
},
"attr": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Attr"
}
},
"required": [
"code",
"detail",
"attr"
],
"title": "MREGError",
"type": "object"
}
},
"description": "MREG error response.",
"properties": {
"type": {
"title": "Type",
"type": "string"
},
"errors": {
"default": [],
"items": {
"$ref": "#/$defs/MREGError"
},
"title": "Errors",
"type": "array"
}
},
"required": [
"type"
],
"title": "MREGErrorResponse",
"type": "object"
}
Fields:
MregValidationError
¶
Bases: MregApiBaseError
Validation error class for MREG API.
Stems from Pydantic ValidationError but adds context about the API request that caused the validation to fail.
from_pydantic
classmethod
¶
from_pydantic(
e: ValidationError, context: str | None = None
) -> MregValidationError
Create an MregValidationError from a Pydantic MregValidationError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
e
|
ValidationError
|
The Pydantic MregValidationError. |
required |
context
|
str | None
|
What was being validated (e.g., "JSON", "string", "object"). |
None
|
Returns:
| Type | Description |
|---|---|
MregValidationError
|
The created MregValidationError. |
MultipleEntitiesFound
¶
NotFoundError
¶
Bases: ClientError
HTTP 404 Not Found.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
PreconditionError
¶
Bases: MregApiBaseError
Client-side guard: an operation's precondition was not met.
Raised before or independently of an HTTP request when the library refuses to perform an operation (e.g. deleting a resource that is still in use).
ResponseError
¶
Bases: MregApiBaseError
Base class for errors that always carry an HTTP response.
Parses error details from the MREG API response if present.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
ServerError
¶
Bases: HTTPStatusError
HTTP 5xx server error.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
TooManyResults
¶
TransportError
¶
Bases: MregApiBaseError
Request was sent but no usable response was received (e.g. connection failure).
UnauthorizedError
¶
Bases: ClientError
HTTP 401 Unauthorized.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
UnexpectedDataError
¶
Bases: UnexpectedResponseError
Deprecated alias for UnexpectedResponseError.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
UnexpectedResponseError
¶
Bases: ResponseError
Server returned a success status but a body/content we could not use.
detail
cached
property
¶
detail: str
Clean human-readable error message from the response.
Joins the detail of each parsed error with "; ". Empty if the response has no parseable errors.
error_message
cached
property
¶
error_message: str
Verbose error text (with codes), falling back to raw response text.
error_message_json
cached
property
¶
error_message_json: str
Verbose error text (with codes), falling back to raw response text.
errors
cached
property
¶
errors: MREGErrorResponse
Get the parsed MREG errors from the response.
Returns:
| Type | Description |
|---|---|
MREGErrorResponse
|
The MREGErrorResponse object, or a default MREGErrorResponse with type |
MREGErrorResponse
|
"unknown" if the response could not be parsed. |
__init__
¶
__init__(message: str = '', *, response: Response)
Initialize a ResponseError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
An optional message override. When empty, the message is
derived from the response via |
''
|
response
|
Response
|
The response object that triggered the exception. |
required |
formatted_message
¶
Get a formatted, human-readable error message.
The message has a status-first header line ({code} {reason}: {method}
{url}) followed by the error detail(s): a pluralized N error(s):
list of the parsed errors, or the endpoint-not-found hint / explicit
message / raw response text otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
bool
|
Render the parsed errors as a JSON block instead of the list. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The formatted error message. |
fmt_error_code
¶
http_error_class
¶
http_error_class(status_code: int) -> type[HTTPStatusError]
Get the appropriate exception class for a given HTTP status code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int
|
The HTTP status code. |
required |
Returns:
| Type | Description |
|---|---|
type[HTTPStatusError]
|
type[HTTPStatusError]: The exception class corresponding to the status code. |
parse_mreg_error
¶
parse_mreg_error(
resp: Response,
) -> MREGErrorResponse | None
Parse an MREG error response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resp
|
Response
|
The response object to parse. |
required |
Returns:
| Type | Description |
|---|---|
MREGErrorResponse | None
|
A MREGErrorResponse object or None if it cannot be parsed. |