Skip to content

Exceptions

Every error the package raises for a mistake in what it was given inherits from ObAnalyticsError, so one except ObAnalyticsError clause catches them all. Each kind of mistake has one type:

  • ConfigError for a bad value: a setting or argument out of range, or input data that is empty or missing columns. It is also a ValueError.
  • UnknownNameError for a name the package does not know: a source, format, metric, feature, bar rule, plot, backend or style. It is also a KeyError. Its message names the known names closest to the one given.

A path that does not exist raises FileNotFoundError, a missing optional dependency raises ImportError, and an argument of the wrong type raises TypeError, as in the standard library.

ObAnalyticsError

Bases: Exception

Base exception for all ob-analytics errors.

ConfigError

Bases: ObAnalyticsError, ValueError

Configuration values or input data are invalid or inconsistent.

UnknownNameError

UnknownNameError(
    kind: str,
    name: object,
    known: Iterable[object],
    hint: str | None = None,
)

Bases: ObAnalyticsError, KeyError

A name is not one the package knows.

The message names the known names closest to name. When none is close, it lists the known names if there are only a few.

Parameters:

Name Type Description Default
kind str

What the name names, for the message, e.g. "source".

required
name object

The name that was given.

required
known iterable

The names that would have been accepted.

required
hint str

A sentence to end the message with, e.g. which backends draw a plot.

None

Attributes:

Name Type Description
kind, name as given
known list of str

The accepted names, as text.