Skip to content

Commit

Permalink
Add a generation error heirarchy
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Nov 15, 2018
1 parent 2c8f6e7 commit 64ba4cb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/into_dbus_python/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,36 @@ class IntoDPError(Exception):
pass


class IntoDPGenerationError(IntoDPError):
"""
Raised when there was a failure to generate a transformer method from
a signature.
"""
pass


class IntoDPParseError(IntoDPGenerationError):
"""
Raised when there was a failure to parse the signature.
"""
_FMT_STR = "failed to parse signature %s"

def __init__(self, signature, msg=None): # pragma: no cover
"""
Initializer.
:param str signature: the D-Bus signature
:param str msg: an explanatory message
"""
self._signature = signature

def __str__(self): # pragma: no cover
if self._msg:
fmt_str = self._FMT_STR + ": %s"
return fmt_str % (self._signature, self._msg)
return self._FMT_STR % self._signature


class IntoDPValueError(IntoDPError):
""" Raised when a parameter has an unacceptable value.
Expand Down

0 comments on commit 64ba4cb

Please sign in to comment.