betty.exception module

Provide exception handling utilities.

exception betty.exception.HumanFacingException

Bases: Exception, Localizable

A localizable, human-facing exception.

When encountering an exception that extends this base class, Betty will show the localized exception message, and no stack trace.

__init__(message: ResolvableLocalizable, *, indicators: Sequence[Indicator] = ())
property indicators: Sequence[Indicator]

Get the human-readable indicators describing where the error occurred in the source data.

The first indicator is the innermost, and the last indicator is the outermost.

localize(localizer: Localizer, /) LocalizedStr

Localize self to a human-readable string.

with_indicator(*indicators: Indicator) None

Adds the given indicator(s) to the exception.

The first indicator is the innermost, and the last indicator is the outermost.

betty.exception.do_raise(exception: BaseException, /) Never

Raise the given exception.

This is helpful as a callback.

betty.exception.reraise_with_indicator(*indicators: Indicator) Iterator[None]

Re-raise a human-facing exception with the given indicators.