Skip to content

Diagnostics

Build and attach sanitized diagnostic details for multimodal exceptions.

add_multimodal_debug_context(error, **context)

Sanitize and add multimodal context to an existing BaseError.

Parameters:

Name Type Description Default
error BaseError

Original BaseError; its public class and message are preserved.

required
**context str

Multimodal operation details added to its debug information.

{}

exception_debug_info(error, **context)

Combine sanitized exception details with multimodal operation context.

Parameters:

Name Type Description Default
error Exception

The original exception being wrapped.

required
**context str

Operation, stage, modality, source kind, and optional component.

{}

Returns:

Type Description
dict[str, str]

Candidate diagnostic fields ready for normalization by an error class.

safe_debug_info(error_class_name, supplied, *, safe_message)

Validate and bound diagnostic values before attaching them to an error.

Parameters:

Name Type Description Default
error_class_name str

Class name of the normalized error.

required
supplied Mapping[str, object] | MultimodalDebugInfo | None

Partial core or multimodal diagnostic mapping.

required
safe_message str

Safe public message used when original details are absent or unsafe.

required

Returns:

Type Description
DebugInfo

A plain dictionary containing validated core and multimodal fields.

safe_exception_diagnostics(error)

Return bounded, sanitized original error details for a normalized wrapper.

Parameters:

Name Type Description Default
error Exception

The caught exception to describe in diagnostic fields.

required

Returns:

Type Description
dict[str, str]

The original error type and sanitized message, plus a sanitized traceback

dict[str, str]

when the exception has one.