Skip to content

Commit 64ba4cb

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

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/into_dbus_python/_errors.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,36 @@ 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+
self._signature = signature
48+
49+
def __str__(self): # pragma: no cover
50+
if self._msg:
51+
fmt_str = self._FMT_STR + ": %s"
52+
return fmt_str % (self._signature, self._msg)
53+
return self._FMT_STR % self._signature
54+
55+
2656
class IntoDPValueError(IntoDPError):
2757
""" Raised when a parameter has an unacceptable value.
2858

0 commit comments

Comments
 (0)