Skip to content

Exceptions

Defines the normalized exceptions raised by gllm-guardrail.

GuardrailEngineConfigError = GuardrailValueError module-attribute

Deprecated alias of GuardrailValueError, kept so existing imports and except clauses keep working.

BaseGuardrailError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseError

Base class of all normalized errors raised by gllm-guardrail.

This class is abstract and is never raised directly.

Attributes:

Name Type Description
code str | None

Stable error code. Defined by each concrete subclass.

default_message str | None

Message used when no message is given. Defined by each concrete subclass.

message str

The message of this error.

debug_info DebugInfo

Structured internal detail about this error.

GuardrailConfigNotFoundError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseGuardrailError, FileNotFoundError

Raised when a packaged guardrail configuration file cannot be found.

The original FileNotFoundError is chained as __cause__.

Attributes:

Name Type Description
code str

Stable error code, GLLM-GRDL-CONFIG-NOT-FOUND.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DebugInfo

Structured internal detail about this error.

GuardrailEngineInitError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseGuardrailError, RuntimeError

Raised when a guardrail engine fails to initialize its underlying vendor components.

The original vendor exception is chained as __cause__, and its detail is stored in debug_info.

Attributes:

Name Type Description
code str

Stable error code, GLLM-GRDL-ENGINE-INIT.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DebugInfo

Structured internal detail about this error.

GuardrailEngineNotInitializedError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseGuardrailError, RuntimeError

Raised when a guardrail engine is used before its underlying components are initialized.

Unlike GuardrailEngineInitError, no vendor failure happened and there is no underlying cause.

Attributes:

Name Type Description
code str

Stable error code, GLLM-GRDL-ENGINE-NOT-INITIALIZED.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DebugInfo

Structured internal detail about this error.

GuardrailNotImplementedError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseGuardrailError, NotImplementedError

Raised when guardrail functionality is not implemented in a subclass.

Attributes:

Name Type Description
code str

Stable error code, GLLM-GRDL-NOT-IMPLEMENTED.

default_message str

Default message used when no message is given.

message str

The message of this error.

debug_info DebugInfo

Structured internal detail about this error.

GuardrailRuntimeError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseGuardrailError, RuntimeError

Raised when a guardrail operation fails at runtime.

Attributes:

Name Type Description
code str

Stable error code, GLLM-GRDL-RUNTIME.

default_message str

Default message used when no message is given.

message str

The message of this error.

debug_info DebugInfo

Structured internal detail about this error.

GuardrailTypeError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseGuardrailError, TypeError

Raised when an argument passed to a guardrail component has the wrong type.

Attributes:

Name Type Description
code str

Stable error code, GLLM-GRDL-TYPE.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DebugInfo

Structured internal detail about this error.

GuardrailValueError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseGuardrailError, ValueError

Raised when a guardrail receives invalid content, configuration, or stream buffer arguments.

This also covers engine configuration that fails to load, merge, or validate. The original vendor exception, when there is one, is chained as __cause__ and its detail is stored in debug_info.

Attributes:

Name Type Description
code str

Stable error code, GLLM-GRDL-VALIDATION.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DebugInfo

Structured internal detail about this error.