diff --git a/src/into_dbus_python/_errors.py b/src/into_dbus_python/_errors.py index 155a76a..1f1b199 100644 --- a/src/into_dbus_python/_errors.py +++ b/src/into_dbus_python/_errors.py @@ -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.