Errors and warnings¶
Every exception pefftacular raises derives from PeffError, and every non-fatal spec violation is
reported as a PeffWarning. See Errors and warnings
for usage.
pefftacular.PeffError
¶
Bases: ValueError
Base class for all pefftacular errors.
Subclasses :class:ValueError for backwards compatibility with callers that
catch ValueError.
pefftacular.PeffParseError
¶
PeffParseError(
message: str,
*,
line: int | None = None,
context: str | None = None,
hint: str | None = None,
)
Bases: PeffError
Raised when PEFF input cannot be parsed.
Attributes:
| Name | Type | Description |
|---|---|---|
line |
1-based absolute line number the failure was detected on, if known. |
|
context |
The offending text (e.g. the raw item that failed to parse). |
|
hint |
A short, actionable suggestion for how to fix the input. |
Source code in src/pefftacular/errors.py
pefftacular.PeffWriteError
¶
Bases: PeffError
Raised when a model object cannot be serialized to PEFF.
Every entry is checked before anything is written, so on this error the destination is left untouched.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
0-based position of the offending entry in the input, if known;
|
|
hint |
A short, actionable suggestion for how to fix the model. |
Source code in src/pefftacular/errors.py
pefftacular.PeffWarning
¶
Bases: UserWarning
Category for non-fatal PEFF spec violations detected while reading.
Parsing stays permissive: the data is always returned, but anything that
violates a spec MUST rule (out-of-range positions, missing required
fields, header/entry-count mismatches, un-coercible custom values, …) is
reported through this category. Because it subclasses :class:UserWarning,
existing UserWarning filters keep working; agents that want to treat PEFF
problems as hard errors can warnings.simplefilter("error", PeffWarning).