Skip to content

Exceptions

Provides custom exception classes, error handling and parsing utilities.

BaseInvokerError(class_name, message, debug_info=None)

Bases: Exception

Base exception class for all gllm_inference invoker errors.

Initialize the base exception.

Parameters:

Name Type Description Default
class_name str

The name of the class that raised the error.

required
message str

The error message.

required
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

verbose()

Verbose error message with debug information.

Returns:

Name Type Description
str str

The verbose error message with debug information.

ExtendedHTTPStatus

Bases: IntEnum

HTTP status codes outside of the standard HTTPStatus enum.

Attributes:

Name Type Description
SERVICE_OVERLOADED int

HTTP status code for service overloaded.

InvokerRuntimeError(class_name, debug_info=None)

Bases: BaseInvokerError

Exception for runtime errors that occur during the invocation of the model.

Corresponds to HTTP status codes other than the ones defined in HTTP_STATUS_TO_EXCEPTION_MAP.

Initialize the InvokerRuntimeError.

Parameters:

Name Type Description Default
class_name str

The name of the class that raised the error.

required
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

ModelNotFoundError(class_name, debug_info=None)

Bases: BaseInvokerError

Exception for model not found errors.

Corresponds to HTTP 404 status code.

Initialize ModelNotFoundError.

Parameters:

Name Type Description Default
class_name str

The name of the class that raised the error.

required
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

ProviderAuthError(class_name, debug_info=None)

Bases: BaseInvokerError

Exception for authorization failures due to API key issues.

Corresponds to HTTP 401-403 status codes.

Initialize ProviderAuthError.

Parameters:

Name Type Description Default
class_name str

The name of the class that raised the error.

required
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

ProviderInternalError(class_name, debug_info=None)

Bases: BaseInvokerError

Exception for unexpected server-side errors.

Corresponds to HTTP 500 status code.

Initialize ProviderInternalError.

Parameters:

Name Type Description Default
class_name str

The name of the class that raised the error.

required
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

ProviderInvalidArgsError(class_name, debug_info=None)

Bases: BaseInvokerError

Exception for bad or malformed requests, invalid parameters or structure.

Corresponds to HTTP 400 status code.

Initialize ProviderInvalidArgsError.

Parameters:

Name Type Description Default
class_name str

The name of the class that raised the error.

required
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

ProviderOverloadedError(class_name, debug_info=None)

Bases: BaseInvokerError

Exception for when the engine is currently overloaded.

Corresponds to HTTP 503, 529 status codes.

Initialize ProviderOverloadedError.

Parameters:

Name Type Description Default
class_name str

The name of the class that raised the error.

required
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

ProviderRateLimitError(class_name, debug_info=None)

Bases: BaseInvokerError

Exception for rate limit violations.

Corresponds to HTTP 429 status code.

Initialize ProviderRateLimitError.

Parameters:

Name Type Description Default
class_name str

The name of the class that raised the error.

required
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

extract_http_status_code(response)

Extract HTTP status code from error message.

This function extracts the HTTP status code from the error message. For example, if the error message is "Error code: 401 - Invalid API key", "HTTP 429 Rate limit exceeded", or "status: 500 Internal server error", the function will return "401", "429", or "500" respectively.

Parameters:

Name Type Description Default
response ErrorResponse

The response object or error message containing HTTP status code.

required

Returns:

Type Description
int | None

int | None: The extracted HTTP status code, or None if not found.

parse_error_message(class_name, error)

Parse error from different AI providers and return appropriate exception type.

This function analyzes the error message and HTTP status code to determine the most appropriate exception type to return.

Parameters:

Name Type Description Default
class_name str

Class name to include in the error message for clarity.

required
error Any

The error object or message from the AI provider. Can be an Exception object, Response object, ClientResponse object, string, or dict that might contain HTTP status information.

required

Returns:

Name Type Description
BaseInvokerError BaseInvokerError

The appropriate exception instance based on error analysis.

Raises:

Type Description
CancelledError

If the original error is a CancelledError.

TimeoutError

If the original error is a TimeoutError.