Errors
Shared error helpers for modality transformers, their configuration models, and their builders.
debug_context(**context)
Add boundary diagnostics to the GLLM errors raised in the block, then re-raise them unchanged.
The context only fills diagnostic fields that are missing or unknown, so a more specific operation or stage set
where the error was raised is kept. The diagnostics are sanitized by add_multimodal_debug_context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**context
|
str
|
Allowlisted diagnostic fields, such as operation, stage, component, and source_kind. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
None |
None
|
Control to the guarded block. |
Raises:
| Type | Description |
|---|---|
BaseError
|
A GLLM error raised by the block, re-raised unchanged with the context added. |
operation_failed_error(error, *, task, reason, stage)
Build the fallback error for a transform step that failed with an error outside the GLLM taxonomy.
The message names only the task and a safe reason. The original error is kept in the sanitized diagnostics, and the caller chains it as the cause.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
Exception
|
The unclassified error raised by the step. |
required |
task
|
str
|
The transform step that failed, such as "image conversion". |
required |
reason
|
str
|
A safe explanation of the failure. |
required |
stage
|
str
|
The allowlisted diagnostic stage of the step, such as "process" or "route". |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MediaOperationFailedError |
MediaOperationFailedError
|
The error to raise from the original error. |
reject_unsupported_options(component, options)
Reject keyword arguments that a component does not accept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
str
|
Name of the component that received the options. |
required |
options
|
Mapping[str, Any]
|
Keyword arguments the component does not use. |
required |
Raises:
| Type | Description |
|---|---|
ComponentConfigError
|
If any option is supplied. The error names each unsupported option. |
validate_converter_configs(component, converter_config)
Check that every converter configuration is a ConverterConfig instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
str
|
Name of the component that received the configuration. |
required |
converter_config
|
Mapping[str, Any]
|
Converter configurations keyed by converter name. |
required |
Raises:
| Type | Description |
|---|---|
ComponentConfigError
|
If any value is not a ConverterConfig instance. |
validate_router_config(component, router_config)
Check that the router configuration is a RouterConfig instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
str
|
Name of the component that received the configuration. |
required |
router_config
|
Any
|
The router configuration to check. |
required |
Raises:
| Type | Description |
|---|---|
ComponentConfigError
|
If router_config is not a RouterConfig instance. |