Skip to content

Commit c9891e2

Browse files
committed
Add a generation error heirarchy
Signed-off-by: mulhern <amulhern@redhat.com>
1 parent 2c8f6e7 commit c9891e2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/into_dbus_python/_errors.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,38 @@ class IntoDPError(Exception):
2323
pass
2424

2525

26+
class IntoDPGenerationError(IntoDPError):
27+
"""
28+
Raised when there was a failure to generate a transformer method from
29+
a signature.
30+
"""
31+
pass
32+
33+
34+
class IntoDPParseError(IntoDPGenerationError):
35+
"""
36+
Raised when there was a failure to parse the signature.
37+
"""
38+
_FMT_STR = "failed to parse signature %s"
39+
40+
def __init__(self, signature, msg=None): # pragma: no cover
41+
"""
42+
Initializer.
43+
44+
:param str signature: the D-Bus signature
45+
:param str msg: an explanatory message
46+
"""
47+
# pylint: disable=super-init-not-called
48+
self._signature = signature
49+
self._msg = msg
50+
51+
def __str__(self): # pragma: no cover
52+
if self._msg:
53+
fmt_str = self._FMT_STR + ": %s"
54+
return fmt_str % (self._signature, self._msg)
55+
return self._FMT_STR % self._signature
56+
57+
2658
class IntoDPValueError(IntoDPError):
2759
""" Raised when a parameter has an unacceptable value.
2860

0 commit comments

Comments
 (0)