Exceptions and validation
Custom exception hierarchy for ferro_ta.
Exception classes
FerroTAError — Base class for all ferro_ta exceptions. FerroTAValueError — Raised for invalid parameter values (e.g. timeperiod < 1). FerroTAInputError — Raised for invalid input arrays (e.g. mismatched lengths, wrong dtype, unexpected NaN/Inf when strict mode is used).
All custom exceptions inherit from both the ferro_ta base and the corresponding
built-in exception (ValueError) so that existing except ValueError clauses
continue to work after upgrading.
Error codes
Every exception carries a code attribute (e.g. "FTERR001") for
programmatic handling:
FTERR001 — Invalid parameter value (FerroTAValueError) FTERR002 — Invalid input array (FerroTAInputError) FTERR003 — Input array too short (FerroTAInputError) FTERR004 — Input arrays have mismatched lengths (FerroTAInputError) FTERR005 — Input array contains NaN or Inf (FerroTAInputError, strict mode) FTERR006 — General Rust-bridge error (FerroTAValueError or FerroTAInputError)
Examples
>>> from ferro_ta.core.exceptions import FerroTAError, FerroTAValueError, FerroTAInputError
>>> raise FerroTAValueError("timeperiod must be >= 1, got 0")
Traceback (most recent call last):
...
ferro_ta.exceptions.FerroTAValueError: [FTERR001] timeperiod must be >= 1, got 0
>>> try:
... raise FerroTAValueError("bad value")
... except FerroTAValueError as exc:
... print(exc.code)
FTERR001
NaN / Inf policy
By default ferro_ta propagates NaN and Inf in input arrays — output values
that depend on a NaN/Inf input will themselves be NaN/Inf. No exception is
raised for NaN or Inf values in the input data. If you need strict mode, call
ferro_ta.exceptions.check_finite() on your arrays before passing them.