Source code for dike.errors
"""
The errors module collects our error types.
Our error tree looks like::
DikeException
|
+-- LabelException
| |
| +- EmptyLabel
| |
| +- LabelTooLong
|
+-- NameException
|
+- NameTooLong
|
+- LabelHasDot
"""
class DikeException(Exception):
"""
Parent of all exceptions raised by the dike library.
"""
class LabelException(DikeException):
"""
Exceptions raised when using Labels.
"""
[docs]class EmptyLabel(LabelException, ValueError):
"""
Exception raised when trying to initialize a label with an empty
value.
"""
class NameException(DikeException):
"""
Exceptions raised when using Names.
"""
[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.fromtuple((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.
"""