allisbns.errors¶
Exceptions specific to the package.
- class allisbns.errors.InvalidISBNReason(*values)¶
Bases:
StrEnumReasons for invalid ISBNs.
Supposed to be used for
allisbns.isbn.MaybeISBNandallisbns.isbn.CanonicalISBN.See also
Examples
While ‘978-0-00-000000-K’ contains the bad check digit (‘K’), we first don’t recognize it as an ISBN with
match_isbn(), and thereforeNOT_ISBNshould be used here. Such reasons (along with bad length, bad characters, etc.) could be taken out into a separate enum, say,NotISBNReason, but we don’t go that far.- NOT_ISBN = 'not_isbn'¶
Not an ISBN.
- BAD_GROUP = 'bad_group'¶
Undefined registration group.
- BAD_REGISTRANT = 'bad_registrant'¶
Undefined registrant.
- BAD_CHECK_DIGIT = 'bad_check_digit'¶
Incorrectly calculated check digit.
- exception allisbns.errors.InvalidISBNError(message: str, reason: InvalidISBNReason, isbn: MaybeISBN | CanonicalISBN)¶
Bases:
AllISBNsError,ValueErrorRaised when an ISBN is not valid.
- __init__(message: str, reason: InvalidISBNReason, isbn: MaybeISBN | CanonicalISBN)¶
Creates an exception with
messageandreasonforisbn.
- exception allisbns.errors.NotISBNError(isbn: MaybeISBN, message: str | None = None)¶
Bases:
InvalidISBNErrorRaised when the value is not an ISBN.
- exception allisbns.errors.UndefinedISBNRangeError(message: str, reason: InvalidISBNReason, isbn: CanonicalISBN)¶
Bases:
InvalidISBNErrorRaised when the registration group or registrant range are undefined.
- __init__(message: str, reason: InvalidISBNReason, isbn: CanonicalISBN)¶
Creates an exception with
messageandreasonforisbn.
- exception allisbns.errors.NotISBN12Error¶
Bases:
AllISBNsError,ValueErrorRaised when a value is not an ISBN-12 number.