xtr_security_csrf.exception ¶
Every error this library raises.
All of them derive from :class:CsrfError, so one except catches
anything minting or checking a token can go wrong with, and a narrower one
handles a single cause. Each carries the data a caller needs as typed
attributes rather than forcing a message to be parsed.
CsrfError ¶
Bases: Exception
Base class for every error raised by this library.
Catch this to handle anything minting or checking a cross-site request forgery token can go wrong with; catch a subclass to handle one cause. Every subclass carries the data a caller needs as typed attributes and composes its own message from them.
InvalidArgumentError ¶
Bases: CsrfError, ValueError
A declaration, configuration or call was malformed.
A generator asked for less entropy than a byte holds — mistakes caught
where they are made. Also a :class:ValueError, so code guarding its
configuration with except ValueError keeps working.
TokenNotFoundError ¶
Bases: CsrfError
No token is stored under the id a caller asked to read.
The manager never raises it — where nothing is stored it mints — it is
the error a storage raises when its get_token is called directly for
an id that holds nothing.
Record which id was asked about and found empty.
Parameters:
-
token_id(str) –The id whose stored value was asked for.