File: stdnum.exceptions.rst

package info (click to toggle)
python-stdnum 1.16-1%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,652 kB
  • sloc: python: 8,088; javascript: 6,995; makefile: 11
file content (31 lines) | stat: -rw-r--r-- 794 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
stdnum.exceptions
=================

.. automodule:: stdnum.exceptions
   :show-inheritance:
   :member-order: bysource
   :members:

   The exceptions are organised hierarchically in the following structure:

   ::

      ValidationError
       +-- InvalidFormat
       |    +-- InvalidLength
       +-- InvalidChecksum
       +-- InvalidComponent

   It is possible to change the exception messages by setting the `message`
   class property. This allows localisation and application-specific error
   messages.

   >>> raise InvalidFormat()
   Traceback (most recent call last):
       ...
   InvalidChecksum: The number has an invalid format.
   >>> InvalidFormat.message = 'UNKNOWN'
   >>> raise InvalidFormat()
   Traceback (most recent call last):
       ...
   InvalidChecksum: UNKNOWN