From c9891e282c47a6f8158c3e606a536b2f65cf7e44 Mon Sep 17 00:00:00 2001 From: mulhern Date: Thu, 15 Nov 2018 10:29:00 -0500 Subject: [PATCH] Add a generation error heirarchy Signed-off-by: mulhern --- src/into_dbus_python/_errors.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/into_dbus_python/_errors.py b/src/into_dbus_python/_errors.py index 155a76a..6cbcb84 100644 --- a/src/into_dbus_python/_errors.py +++ b/src/into_dbus_python/_errors.py @@ -23,6 +23,38 @@ 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 + """ + # pylint: disable=super-init-not-called + self._signature = signature + self._msg = msg + + 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.