Skip to content

Exceptions

Custom exception and warning classes used by the library.

exceptions

Exception hierarchy for the tunas library.

TunasError

Bases: Exception

Base exception for all tunas library errors.

ParseError

ParseError(warning: ParseWarning)

Bases: TunasError

Raised on a fatal structural violation, or on warnings in strict mode.

Attributes:

Name Type Description
warning

The originating ParseWarning that triggered this error.

Source code in src/tunas/exceptions.py
def __init__(self, warning: ParseWarning) -> None:
    self.warning = warning
    super().__init__(
        f"{warning.source}:{warning.line_no} "
        f"[{warning.severity.value}] "
        f"{warning.record_type or '??'}"
        f"{'.' + warning.field if warning.field else ''}: {warning.reason}"
    )

StandardsError

Bases: TunasError

Raised when bundled time-standards data is missing or inconsistent.