Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a generation error hierarchy #19

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/into_dbus_python/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down