Skip to content

Exceptions

Exception classes — verbatim port of legacy gffutils.exceptions.

Same names, same constructors, same attributes. Downstream code that catches gffutils.FeatureNotFoundError works against gffbase.FeatureNotFoundError.

GFFFormatError

GFFFormatError(message: str = '', *, line_no: int = 0, kind: str = '')

Bases: ValueError

Raised when a GFF3 line violates the spec.

Inherits from ValueError so legacy code that catches ValueError keeps working — but the dedicated subclass carries structured fields line_no, kind, and message that point callers straight to the offender in the input.

Phase 16: when the Rust extension is loaded, the canonical class is gffbase._native.GFFFormatError (a PyO3 create_exception! type). At import time, gffbase.__init__ rebinds the public name to whichever class is actually live so isinstance and except clauses keep working regardless of which path raised.

Source code in python/gffbase/exceptions.py
def __init__(self, message: str = "", *, line_no: int = 0, kind: str = ""):
    super().__init__(message)
    self.message = message
    self.line_no = line_no
    self.kind = kind

FeatureNotFoundError

FeatureNotFoundError(feature_id: str)

Bases: Exception

Raised by FeatureDB.__getitem__ when the requested ID is absent.

Source code in python/gffbase/exceptions.py
def __init__(self, feature_id: str):
    Exception.__init__(self, f"feature not found: {feature_id}")
    self.feature_id = feature_id

DuplicateIDError

Bases: Exception

Raised during ingestion when a duplicate ID is encountered with merge_strategy='error' (Phase 6 will wire merge_strategy).

AttributeStringError

Bases: Exception

Raised on malformed col-9 attributes.

EmptyInputError

Bases: Exception

Raised when an input file or iterable yields no features.