# Exceptions¶

exception itsdangerous.exc.BadData(message)

Raised if bad data of any sort was encountered. This is the base for all exceptions that itsdangerous defines.

New in version 0.15.

exception itsdangerous.exc.BadSignature(message, payload=None)

Raised if a signature does not match.

payload = None

The payload that failed the signature test. In some situations you might still want to inspect this, even if you know it was tampered with.

New in version 0.14.

exception itsdangerous.exc.BadTimeSignature(message, payload=None, date_signed=None)

Raised if a time-based signature is invalid. This is a subclass of BadSignature.

date_signed = None

If the signature expired this exposes the date of when the signature was created. This can be helpful in order to tell the user how long a link has been gone stale.

New in version 0.14.

exception itsdangerous.exc.SignatureExpired(message, payload=None, date_signed=None)

Raised if a signature timestamp is older than max_age. This is a subclass of BadTimeSignature.

exception itsdangerous.exc.BadHeader(message, payload=None, header=None, original_error=None)

Raised if a signed header is invalid in some form. This only happens for serializers that have a header that goes with the signature.

New in version 0.24.

header = None

If the header is actually available but just malformed it might be stored here.

original_error = None

If available, the error that indicates why the payload was not valid. This might be None.

exception itsdangerous.exc.BadPayload(message, original_error=None)

Raised if a payload is invalid. This could happen if the payload is loaded despite an invalid signature, or if there is a mismatch between the serializer and deserializer. The original exception that occurred during loading is stored on as original_error.

New in version 0.15.

original_error = None

If available, the error that indicates why the payload was not valid. This might be None.