Exceptions
Defines the normalized exceptions raised by gllm-privacy.
Every concrete error has a stable code (GLLM-PRIV-<NAME>) and a default_message. Each error also keeps the
builtin ancestry of the error it replaced (ValueError, ImportError or RuntimeError), so existing except
clauses keep matching.
debug_info never holds the analyzed text, request payloads, response bodies, headers, or URL query strings.
recovery says whether retrying can succeed. Remote timeout, connection, rate limit and server errors are
retryable, and a rate limit or server error carries retry_after_seconds when the service sends Retry-After.
Every other error keeps the {"retryable": False} default.
BasePrivacyError(message=None, *, debug_info=None, recovery=None)
Bases: BaseError
Root of the normalized errors raised by gllm-privacy.
This class is abstract and is never raised directly. Every concrete subclass defines its own code
(GLLM-PRIV-<NAME>) and default_message.
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 |
PrivacyDebugInfo
|
Structured internal detail about this error. |
recovery |
RecoveryInfo
|
Whether retrying can succeed. Defaults to |
BaseRemoteRecognizerError(message=None, *, debug_info=None, recovery=None)
Bases: BasePrivacyError, RuntimeError
Base class of the errors raised when a remote NER service call fails.
This class is abstract and is never raised directly. Catch it to handle every remote recognizer failure.
The original transport error is chained as __cause__, and its sanitized detail is stored in debug_info.
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 |
PrivacyDebugInfo
|
Structured internal detail, such as |
InvalidConfigError(message=None, *, debug_info=None, recovery=None)
Bases: BasePrivacyError, ValueError
Raised when a recognizer, chunker or other component is given an invalid configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail, such as |
InvalidInputError(message=None, *, debug_info=None, recovery=None)
Bases: BasePrivacyError, ValueError
Raised when the input of an analyzer or anonymizer is missing or invalid.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail, such as |
MissingDependencyError(message=None, *, debug_info=None, recovery=None)
Bases: BasePrivacyError, ImportError
Raised when an optional dependency needed by a component is not installed.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
ModelInferenceError(message=None, *, debug_info=None, recovery=None)
Bases: BasePrivacyError, RuntimeError
Raised when the NER model fails while predicting entities in the text.
The original error is chained as __cause__, and its detail is stored in debug_info.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
ModelLoadError(message=None, *, debug_info=None, recovery=None)
Bases: BasePrivacyError, RuntimeError
Raised when the NER model, tokenizer or pipeline cannot be loaded.
The original error is chained as __cause__, and its detail is stored in debug_info.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
ModelOutputError(message=None, *, debug_info=None, recovery=None)
Bases: BasePrivacyError, ValueError
Raised when the NER model returns a result that does not match its input.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
PrivacyDebugInfo
Bases: DebugInfo
Structured internal detail attached to the errors raised by gllm-privacy.
Extends DebugInfo with the keys specific to privacy errors. This is a type-level contract only.
Attributes:
| Name | Type | Description |
|---|---|---|
class_name |
str
|
Name of the exception class. Always present. |
error_type |
str
|
Type name of the original error, when one was caught. |
original_message |
str
|
Sanitized message of the original error, when one was caught. |
traceback |
str
|
Formatted stack frames of the original error, when one was caught. |
parameter |
str
|
Name of the input or configuration parameter involved, when applicable. |
language |
str
|
Language code involved, when applicable. |
recognizer |
str
|
Name of the recognizer class involved, when applicable. |
endpoint |
str
|
Remote endpoint as scheme, host and path only, when applicable. |
status_code |
int
|
HTTP status code returned by the remote service, when applicable. |
PrivacyRuntimeError(message=None, *, debug_info=None, recovery=None)
Bases: BasePrivacyError, RuntimeError
Raised when an internal step of gllm-privacy fails unexpectedly.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
RemoteRecognizerAuthError(message=None, *, debug_info=None, recovery=None)
Bases: BaseRemoteRecognizerError
Raised when the remote NER service rejects the credentials (HTTP 401 or 403). Do not retry as is.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
RemoteRecognizerConnectionError(message=None, *, debug_info=None, recovery=None)
Bases: BaseRemoteRecognizerError
Raised when the remote NER service cannot be reached. Safe to retry.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
recovery |
RecoveryInfo
|
|
RemoteRecognizerInvalidResponseError(message=None, *, debug_info=None, recovery=None)
Bases: BaseRemoteRecognizerError
Raised when the remote NER service returns a response in an unexpected format.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
RemoteRecognizerRateLimitError(message=None, *, debug_info=None, recovery=None)
Bases: BaseRemoteRecognizerError
Raised when the remote NER service throttles the request (HTTP 429). Retry after a delay.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
recovery |
RecoveryInfo
|
|
RemoteRecognizerRequestError(message=None, *, debug_info=None, recovery=None)
Bases: BaseRemoteRecognizerError
Raised when the remote NER request fails for any other reason, such as another HTTP 4xx status.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
RemoteRecognizerServerError(message=None, *, debug_info=None, recovery=None)
Bases: BaseRemoteRecognizerError
Raised when the remote NER service fails on its side (HTTP 5xx). Safe to retry.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
recovery |
RecoveryInfo
|
|
RemoteRecognizerTLSError(message=None, *, debug_info=None, recovery=None)
Bases: BaseRemoteRecognizerError
Raised when the TLS handshake with the remote NER service fails. Do not retry as is.
This covers a rejected or invalid client certificate (mTLS), and a server certificate that cannot be verified.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
RemoteRecognizerTimeoutError(message=None, *, debug_info=None, recovery=None)
Bases: BaseRemoteRecognizerError
Raised when the remote NER service does not respond within the timeout. Safe to retry.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |
recovery |
RecoveryInfo
|
|
UnsupportedLanguageError(message=None, *, debug_info=None, recovery=None)
Bases: BasePrivacyError, ValueError
Raised when a component is asked to process a language it does not support.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail, such as |
UnsupportedTokenizerError(message=None, *, debug_info=None, recovery=None)
Bases: BasePrivacyError, ValueError
Raised when a tokenizer cannot provide the character offsets needed to chunk text.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
Stable error code, |
default_message |
str
|
Message used when no message is given. |
message |
str
|
The message of this error. |
debug_info |
PrivacyDebugInfo
|
Structured internal detail about this error. |