Skip to content

Exceptions

Every error raised by AnomalyBench inherits from dataexcept.DataExceptError, so one except clause catches all of them:

from dataexcept import DataExceptError

try:
    detector.score(data)
except DataExceptError as exc:
    ...

These are not ValueError subclasses

The exceptions do not inherit from ValueError, KeyError, or TypeError. Code written against an earlier version that caught those builtins will no longer catch these — catch the DataExcept types instead.

What is raised where

DataExcept supplies structured exceptions for most data and model failures, and they are used directly wherever one fits:

Exception Raised when
ConfigurationError a config key is malformed, or a detector key collides
DataValidationError inputs fail a shape or content check
DataFormatError a dataset file cannot be parsed as expected
DependencyError an optional extra is missing, or Python is unsupported
HyperparameterError a search grid or parameter value is invalid

Three cases have no direct DataExcept equivalent and are defined here:

Exception Raised when
DetectorNotFittedError score() is called before fit()
UnknownDetectorError a detector key is absent from the registry
UnknownDatasetError a selector names something the catalog does not hold

Full signatures are in the API reference.

UnknownDetectorError and UnknownDatasetError carry an available attribute and list the valid keys in the message, so a typo tells you what you meant instead of just that you were wrong.