Skip to content

yggdrasil.pyutils.exceptions

exceptions

Utilities for parsing and re-raising exceptions from traceback strings.

ParsedException dataclass

ParsedException(
    exc_type: Type[BaseException], message: str, raw_type_name: str
)

Structured representation of a parsed exception type and message.

RemoteTraceback

RemoteTraceback(traceback_text: str)

Bases: Exception

Holds a traceback string and prints it as the chained cause.

Store the traceback text for later display.

Parameters:

Name Type Description Default
traceback_text str

Traceback string to store.

required

Returns:

Type Description
None

None.

parse_exception_from_traceback

parse_exception_from_traceback(tb_text: str) -> ParsedException

Parse a traceback string, infer exception class + message. Falls back to RuntimeError if it can't infer a proper built-in exception.

raise_parsed_traceback

raise_parsed_traceback(tb_text: str, *, attach_as_cause: bool = True) -> None

Infer exception from traceback text and raise it. Note: cannot recreate original frames; we chain the text as the cause by default.