Exceptions

class flame_hub._exceptions.ErrorResponse(*, statusCode: int, code: str, message: str, **extra_data: Any)

Bases: BaseModel

model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration so that extra properties may be available.

status_code: Annotated[int, FieldInfo(annotation=NoneType, required=True, alias_priority=2, validation_alias='statusCode')]

The status code of the response. This attribute is mapped to the "statusCode" field of the response.

code: str

Written equivalent for status_code.

message: str

The error message.

class flame_hub.HubAPIError(message: str, request: Request, error: ErrorResponse = None)

Bases: HTTPError

Base error for any unexpected response returned by the Hub API.

Parameters:
messagestr

The error message.

requesthttpx.Request

The request which caused the error.

errorErrorResponse, optional

Parsed response to enrich the error with additional information.

flame_hub._exceptions.new_hub_api_error_from_response(r: Response) HubAPIError

Create a new HubAPIError from a response.

If present, this function will use the response body to add context to the error message. The response body is parsed by the ErrorResponse model and is available using the error_response property of the returned error.

Parameters:
rhttpx.Response

The response to create a new HubAPIError for.

Returns:
HubAPIError

A new HubAPIError instance which is enriched with information from the response r.