Source code for errors
"""
The errors module collects our error types.
Our error tree looks like::
DikeException
|
+-- NameException
|
+- EmptyLabel
|
+- LabelTooLong
|
+- NameTooLong
|
+- LabelHasDot
"""
[docs]class DikeException(Exception):
"""
Parent of all exceptions raised by the dike library.
"""
[docs]class NameException(DikeException):
"""
Exceptions raised when using Names.
"""
[docs]class EmptyLabel(NameException, ValueError):
"""
Exception raised when trying to initialize a label with an empty
value.
"""
[docs]class LabelHasDot(NameException, ValueError):
"""
Exception raised when trying to convert a name to a string or
bytes value which has a dot, ``'.'``, *in* a label. In that case,
we cannot convert to a string or bytes value, since it would be
impossible to tell which ``'.'`` are separators and which are part
of a label.
For example::
# very legal and very cool
label_with_dot = Label('label.with.dot')
le_name = Name((label_with_dot, 'example', 'com'))
# but this will raise LabelHasDot
print(le_name)
If you need to work with names that might possibly contain a dot
in them (for example if processing packets from the Internet), you
can treat labels separately, or use the wire or presentation
format for names.
"""