"""Custom exceptions for steplib."""from__future__importannotations
[docs]classSteplibError(Exception):"""Base exception for all steplib errors."""
[docs]classMissingDependencyError(SteplibError):"""Raised when an optional dependency (extra) is not installed. Attributes: extra: The name of the missing extra (e.g. ``"api"``, ``"kit"``). package: The import name of the missing package, if known. """def__init__(self,extra:str,package:str|None=None)->None:"""Initialize the error with the missing extra name."""self.extra=extraself.package=packagepkg_hint=f" (package '{package}')"ifpackageelse""super().__init__(f"Missing optional dependency for extra '{extra}'{pkg_hint}. "f"Install it with: pip install behave-steplib[{extra}]")
[docs]classDuplicateStepError(SteplibError):"""Raised when two steps register the same pattern in the same backend."""def__init__(self,pattern:str,backend:str|None=None)->None:"""Initialize the error with the duplicate pattern and backend."""self.pattern=patternself.backend=backendbackend_hint=f" (backend '{backend}')"ifbackendelse""super().__init__(f"Duplicate step pattern: '{pattern}'{backend_hint}")
[docs]classStepContractError(SteplibError):"""Raised when a step function does not satisfy the step contract."""