Skip to content

Exceptions

Provides custom exception classes, error handling and parsing utilities.

APIConnectionError(class_name, message='', debug_info=None)

Bases: BaseInvokerError

Exception for when the client fails to connect to the model provider.

Attributes:

Name Type Description
class_name str

The name of the class that raised the error.

message str

The error message.

debug_info dict[str, Any]

Additional debug information for developers.

default_message str

Default error message for the exception class.

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. If empty, uses the class's default_message. Defaults to empty string.

''
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

APITimeoutError(class_name, message='', debug_info=None)

Bases: BaseInvokerError

Exception for when the request to the model provider times out.

Attributes:

Name Type Description
class_name str

The name of the class that raised the error.

message str

The error message.

debug_info dict[str, Any]

Additional debug information for developers.

default_message str

Default error message for the exception class.

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. If empty, uses the class's default_message. Defaults to empty string.

''
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

BaseInvokerError(class_name, message='', debug_info=None)

Bases: Exception

Base exception class for all gllm_inference invoker errors.

Attributes:

Name Type Description
class_name str

The name of the class that raised the error.

message str

The error message.

debug_info dict[str, Any]

Additional debug information for developers.

default_message str

Default error message for the exception class.

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. If empty, uses the class's default_message. Defaults to empty string.

''
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.

ContextOverflowError(class_name, message='', debug_info=None)

Bases: BaseInvokerError

Exception for when input size exceeds the model's context length limit.

Attributes:

Name Type Description
class_name str

The name of the class that raised the error.

message str

The error message.

debug_info dict[str, Any]

Additional debug information for developers.

default_message str

Default error message for the exception class.

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. If empty, uses the class's default_message. Defaults to empty string.

''
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

InvokerRuntimeError(class_name, message='', debug_info=None)

Bases: BaseInvokerError

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

Attributes:

Name Type Description
class_name str

The name of the class that raised the error.

message str

The error message.

debug_info dict[str, Any]

Additional debug information for developers.

default_message str

Default error message for the exception class.

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. If empty, uses the class's default_message. Defaults to empty string.

''
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

ModelNotFoundError(class_name, message='', debug_info=None)

Bases: BaseInvokerError

Exception for model not found errors.

Attributes:

Name Type Description
class_name str

The name of the class that raised the error.

message str

The error message.

debug_info dict[str, Any]

Additional debug information for developers.

default_message str

Default error message for the exception class.

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. If empty, uses the class's default_message. Defaults to empty string.

''
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

ProviderAuthError(class_name, message='', debug_info=None)

Bases: BaseInvokerError

Exception for authorization failures due to API key issues.

Attributes:

Name Type Description
class_name str

The name of the class that raised the error.

message str

The error message.

debug_info dict[str, Any]

Additional debug information for developers.

default_message str

Default error message for the exception class.

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. If empty, uses the class's default_message. Defaults to empty string.

''
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

no_organization(class_name, debug_info=None) classmethod

Factory for 'no organization' variant.

ProviderConflictError(class_name, message='', debug_info=None)

Bases: BaseInvokerError

Exception for when the request to the model provider conflicts.

Attributes:

Name Type Description
class_name str

The name of the class that raised the error.

message str

The error message.

debug_info dict[str, Any]

Additional debug information for developers.

default_message str

Default error message for the exception class.

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. If empty, uses the class's default_message. Defaults to empty string.

''
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

ProviderInternalError(class_name, message='', debug_info=None)

Bases: BaseInvokerError

Exception for unexpected server-side errors.

Attributes:

Name Type Description
class_name str

The name of the class that raised the error.

message str

The error message.

debug_info dict[str, Any]

Additional debug information for developers.

default_message str

Default error message for the exception class.

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. If empty, uses the class's default_message. Defaults to empty string.

''
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

ProviderInvalidArgsError(class_name, message='', debug_info=None)

Bases: BaseInvokerError

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

Attributes:

Name Type Description
class_name str

The name of the class that raised the error.

message str

The error message.

debug_info dict[str, Any]

Additional debug information for developers.

default_message str

Default error message for the exception class.

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. If empty, uses the class's default_message. Defaults to empty string.

''
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

ProviderOverloadedError(class_name, message='', debug_info=None)

Bases: BaseInvokerError

Exception for when the engine is currently overloaded.

Attributes:

Name Type Description
class_name str

The name of the class that raised the error.

message str

The error message.

debug_info dict[str, Any]

Additional debug information for developers.

default_message str

Default error message for the exception class.

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. If empty, uses the class's default_message. Defaults to empty string.

''
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

ProviderRateLimitError(class_name, message='', debug_info=None)

Bases: BaseInvokerError

Exception for rate limit violations.

Attributes:

Name Type Description
class_name str

The name of the class that raised the error.

message str

The error message.

debug_info dict[str, Any]

Additional debug information for developers.

default_message str

Default error message for the exception class.

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. If empty, uses the class's default_message. Defaults to empty string.

''
debug_info dict[str, Any] | None

Additional debug information for developers. Defaults to None.

None

build_debug_info(error, class_name)

Build debug information for an error.

Parameters:

Name Type Description Default
error Any

The error to extract debug information from.

required
class_name str

The name of the class that raised the error.

required

Returns:

Type Description
dict[str, Any]

dict[str, Any]: A dictionary containing debug information about the error.

convert_to_base_invoker_error(error, invoker, status_code_extractor=None, response_detail_extractor=None, message_extractor=None, response_detail_mapping=None, message_mapping=None)

Convert provider error from exception to BaseInvokerError.

The resolution follows this priority (stops at first match): 1. Provider-specific error details (via response_detail_extractor + response_detail_mapping). 2. Error message regex matching (via message_extractor + message_mapping). 3. HTTP status code mapping (via status_code_extractor). 4. Generic provider exception from class module and name. 5. If all extraction attempts fail, fall back to InvokerRuntimeError.

Parameters:

Name Type Description Default
error Exception

The error to convert.

required
invoker BaseEMInvoker | BaseLMInvoker

The invoker instance that raised the error.

required
status_code_extractor Callable[[Exception], int | None] | None

Function to extract HTTP status code from the error. Defaults to None.

None
response_detail_extractor Callable[[Exception], str | None] | None

Function to extract error code/type from the error. Defaults to None.

None
message_extractor Callable[[Exception], str | None] | None

Function to extract error message from the error. Defaults to None, in which case the error message will be extracted from the error's str(error).

None
response_detail_mapping dict[str, type[BaseInvokerError]] | None

Fine-grained mapping from provider error codes/types that overrides the default error mapping. The mapping key is the response detail string, and the value is the exception class object. Defaults to None.

None
message_mapping dict[str, type[BaseInvokerError]] | None

Fine-grained mapping from provider error messages that overrides the default error mapping. The mapping key is the regex, and the value is the exception class object. Defaults to None.

None

Returns:

Name Type Description
BaseInvokerError BaseInvokerError

The converted error.

get_exception_key(error)

Generate the fully-qualified name key for an exception.

Parameters:

Name Type Description Default
error Exception

The exception object.

required

Returns:

Name Type Description
str str

The fully-qualified name in format "module.ClassName".