Exceptions

class flame_hub._exceptions.ErrorResponse(*, code: str = '', status_code: int | None = None, message: str = '', issues: list = <factory>, **extra_data: ~typing.Any)

Bases: BaseModel

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

Configuration so that extra properties may be available.

code: str

Name of the error code.

status_code: int | None

HTTP code of the response.

message: str

The error message.

issues: list

List of issues.

class flame_hub.HubAPIError(message: str, request: Request, headers: Headers = Headers({}), error: ErrorResponse | None = None, error_model_traceback: str = '')

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.

headershttpx.Headers, optional

The headers of the unexpected response.

errorErrorResponse, optional

Parsed response to enrich the error with additional information.

error_model_tracebackstr, optional

Holds the traceback if there is an error while validating the unexpected response against the ErrorResponse model.

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.