summaryrefslogtreecommitdiff
path: root/dbus/exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'dbus/exceptions.py')
-rw-r--r--dbus/exceptions.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/dbus/exceptions.py b/dbus/exceptions.py
index 6a0fbaf..8d84a29 100644
--- a/dbus/exceptions.py
+++ b/dbus/exceptions.py
@@ -28,6 +28,17 @@ __all__ = ('DBusException', 'MissingErrorHandlerException',
'NameExistsException')
class DBusException(Exception):
+
+ include_traceback = False
+ """If True, tracebacks will be included in the exception message sent to
+ D-Bus clients.
+
+ Exceptions that are not DBusException subclasses always behave
+ as though this is True. Set this to True on DBusException subclasses
+ that represent a programming error, and leave it False on subclasses that
+ represent an expected failure condition (e.g. a network server not
+ responding)."""
+
def __init__(self, *args, **kwargs):
name = kwargs.pop('name', None)
if name is not None or getattr(self, '_dbus_error_name', None) is None:
@@ -44,30 +55,52 @@ class DBusException(Exception):
else:
return s
+ def get_dbus_message(self):
+ s = Exception.__str__(self)
+ return s.decode('utf-8', 'replace')
+
def get_dbus_name(self):
return self._dbus_error_name
class MissingErrorHandlerException(DBusException):
+
+ include_traceback = True
+
def __init__(self):
DBusException.__init__(self, "error_handler not defined: if you define a reply_handler you must also define an error_handler")
class MissingReplyHandlerException(DBusException):
+
+ include_traceback = True
+
def __init__(self):
DBusException.__init__(self, "reply_handler not defined: if you define an error_handler you must also define a reply_handler")
class ValidationException(DBusException):
+
+ include_traceback = True
+
def __init__(self, msg=''):
DBusException.__init__(self, "Error validating string: %s"%msg)
class IntrospectionParserException(DBusException):
+
+ include_traceback = True
+
def __init__(self, msg=''):
DBusException.__init__(self, "Error parsing introspect data: %s"%msg)
class UnknownMethodException(DBusException):
+
+ include_traceback = True
_dbus_error_name = 'org.freedesktop.DBus.Error.UnknownMethod'
+
def __init__(self, method):
DBusException.__init__(self, "Unknown method: %s"%method)
class NameExistsException(DBusException):
+
+ include_traceback = True
+
def __init__(self, name):
DBusException.__init__(self, "Bus name already exists: %s"%name)