Errors#
- class AnzaError(code: Literal['VALIDATION', 'NOT_FOUND', 'TEMPLATE', 'CRYPTO', 'INTERNAL'], message: str)[source]#
An engine error with a stable code.
str(error)is"[Anza:<code>] <message>".Code
Raised for
VALIDATIONBad input: an empty route, template or slot, a malformed template name, a template root that does not exist.
NOT_FOUNDAn unknown page route or template, a fragment outside the
fragmentsallowlist, a template that resolves outside the root or cannot be read.TEMPLATEA template that is not UTF-8, is larger than
max_template_bytesor has an unclosed/empty placeholder.CRYPTOA missing, short or mismatched signing key, and every failed envelope check in
verify_envelope().INTERNALAn unexpected engine failure.
- Parameters:
code – One of the codes above.
message – What went wrong.
- code#
The error code.
- message#
The message, without the
[Anza:<code>]prefix.
Example
>>> from anza import AnzaError >>> err = AnzaError.not_found("Page not found") >>> err.code, err.message ('NOT_FOUND', 'Page not found') >>> str(err) '[Anza:NOT_FOUND] Page not found'