Skip to content

Processing

Media processing exception family.

MediaOperationConfigError(*, component, parameter, next_step, debug_info=None)

Bases: MediaOperationError, ValueError

Report invalid or incomplete options for a media operation.

Use this when one processing call lacks a required option, such as frame timestamps, while the processor itself is configured and available.

Example

A frame extraction request omits its timestamps.

from gllm_multimodal.exceptions import MediaOperationConfigError

error = MediaOperationConfigError(
    component="Frame extraction",
    parameter="timestamps",
    next_step="Pass process_config.timestamps or call set_timestamps().",
)
print(error.message)
Output:
Frame extraction requires timestamps. Pass process_config.timestamps or call set_timestamps().

Initialize a configuration error with context and recovery guidance.

Parameters:

Name Type Description Default
component str

Name of the media operation that needs configuration.

required
parameter str

Required option or setting that is missing or invalid.

required
next_step str

Action for supplying or correcting the parameter.

required
debug_info DebugInfo | None

Optional diagnostic context, sanitized before storage.

None

from_validation_error(error, *, component, subject, default_parameter, debug_info=None) classmethod

Create the error from a pydantic validation failure of one call's options.

The error names the first offending field and repeats pydantic's reason in its next step. An unknown option, or a failure that is not tied to one field, is reported against default_parameter.

Example

A frame sampling call passes a non-positive frame rate.

error = MediaOperationConfigError.from_validation_error(
    validation_error,
    component="Frame sampling",
    subject="process_config options",
    default_parameter="process_config",
)
print(error.message)
Output:
Frame sampling requires target_fps. Check the process_config options: target_fps must be greater than 0.

Parameters:

Name Type Description Default
error ValidationError

The pydantic validation failure.

required
component str

Name of the media operation whose options are invalid.

required
subject str

What the caller should check, named in the next step, such as "process_config options".

required
default_parameter str

Parameter reported when the failure is not tied to a single valid field.

required
debug_info DebugInfo | None

Optional diagnostic context, sanitized before storage.

None

Returns:

Type Description
Self

The configuration error. The caller raises it from error.

MediaOperationConfigTypeError(*, component, parameter, next_step, debug_info=None)

Bases: MediaOperationConfigError, TypeError

Report an invalid config type while preserving TypeError compatibility.

This concrete compatibility error is raised when callers pass an unsupported process_config object. It has its own code so it can be raised directly.

MediaOperationError(*, debug_info=None, _message=None, message_values=None)

Bases: MultimodalError

Abstract family for failures while an operation processes accepted input.

Use this family when decoding, extracting, or converting accepted media fails.

Example

Handle a processing failure after an input has been accepted.

from gllm_multimodal.exceptions import MediaOperationError, MediaOperationTimeoutError

try:
    raise MediaOperationTimeoutError(
        task="frame extraction",
        reason="decoding exceeded 30 seconds",
        next_step="Try a shorter video.",
    )
except MediaOperationError as error:
    print(error.message)
Output:
The frame extraction operation failed due to timeout: decoding exceeded 30 seconds. Try a shorter video.

MediaOperationFailedError(*, task=None, reason=None, next_step=None, debug_info=None)

Bases: MediaOperationError, RuntimeError

Report a failed media operation, including file inspection or content reading.

Use this when an accepted input cannot be processed and the cause can be summarized safely for the caller.

Example

Frame extraction fails because the decoder produces no frames.

from gllm_multimodal.exceptions import MediaOperationFailedError

error = MediaOperationFailedError(
    task="frame extraction",
    reason="the decoder produced no frames",
    next_step="Check the video file and try again.",
)
print(error.message)
Output:
The frame extraction operation failed: the decoder produced no frames. Check the video file and try again.

Initialize an operation failure with optional task guidance.

Parameters:

Name Type Description Default
task str | None

Operation name included in the message. Defaults to "media".

None
reason str | None

Safe summary of why the operation failed. Defaults to "the cause is unknown".

None
next_step str | None

Suggested recovery action. Defaults to checking the input and processing options, then trying again.

None
debug_info DebugInfo | None

Optional diagnostic context, sanitized before storage.

None

MediaOperationTimeoutError(*, task, reason, next_step, debug_info=None)

Bases: MediaOperationError, TimeoutError

Report an operation that failed because it exceeded its time limit.

Use this when an operation starts successfully but runs past its deadline.

Example

A frame extraction job reaches its processing timeout.

from gllm_multimodal.exceptions import MediaOperationTimeoutError

error = MediaOperationTimeoutError(
    task="frame extraction",
    reason="decoding exceeded 30 seconds",
    next_step="Try a shorter video.",
)
print(error.message)
Output:
The frame extraction operation failed due to timeout: decoding exceeded 30 seconds. Try a shorter video.

Initialize a timeout with its task, cause, and recovery action.

Parameters:

Name Type Description Default
task str

Operation that exceeded its time limit.

required
reason str

Safe explanation of what timed out.

required
next_step str

Action the caller can take to recover.

required
debug_info DebugInfo | None

Optional diagnostic context, sanitized before storage.

None

MediaResultOperationError(*, task=None, next_step=None, debug_info=None)

Bases: MediaOperationError, ValueError

Report a missing or invalid result from an otherwise completed operation.

Use this when a backend reports success but omits data that the caller needs.

Example

A segmentation operation returns no segment metadata.

from gllm_multimodal.exceptions import MediaResultOperationError

error = MediaResultOperationError(
    task="segmentation",
    next_step="Check that the backend returns segment metadata.",
)
print(error.message)
Output:
The segmentation result is missing or has an unexpected format. Check that the backend returns segment metadata.

Initialize an invalid result error with optional task guidance.

Parameters:

Name Type Description Default
task str | None

Operation name included in the message. Defaults to "media operation".

None
next_step str | None

Suggested recovery action. Defaults to checking the selected service or backend output, then trying again.

None
debug_info DebugInfo | None

Optional diagnostic context, sanitized before storage.

None

from_validation_error(error, *, task, subject, default_parameter, debug_info=None) classmethod

Create the error from a pydantic validation failure of an operation's result.

The error names the first offending field and repeats pydantic's reason in its next step. A failure that is not tied to one field is reported against default_parameter. The rejected value is never included.

Example

A captioner returns a segment without a start time.

error = MediaResultOperationError.from_validation_error(
    validation_error,
    task="video caption",
    subject="video captioner segment 0",
    default_parameter="segment",
)
print(error.message)
Output:
The video caption result is missing or has an unexpected format. Check the video captioner segment 0: start_time: Field required.

Parameters:

Name Type Description Default
error ValidationError

The pydantic validation failure.

required
task str

Operation name included in the message.

required
subject str

What the caller should check, named in the next step, such as "video captioner segment 0".

required
default_parameter str

Parameter reported when the failure is not tied to a single valid field.

required
debug_info DebugInfo | None

Optional diagnostic context, sanitized before storage.

None

Returns:

Type Description
Self

The result error. The caller raises it from error.