blob: 620fdf0eea82b9229f5d7d0f687187e1da348a57 (
plain)
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
|