_dbus_bindings/mainloop.c: Remove Watch and Timeout.
[dbus-python-phuang.git] / dbus / exceptions.py
blob545d62fa70a1430962cbbf272b336b40a52d66b5
1 """D-Bus exceptions."""
3 __all__ = ('DBusException', 'MissingErrorHandlerException',
4 'MissingReplyHandlerException', 'ValidationException',
5 'IntrospectionParserException', 'UnknownMethodException',
6 'NameExistsException')
8 class DBusException(Exception):
9 def __init__(self, *args, **kwargs):
10 self._dbus_error_name = kwargs.pop('name', None)
11 if kwargs:
12 raise TypeError('DBusException does not take keyword arguments: %s'
13 % ', '.join(kwargs.keys()))
14 Exception.__init__(self, *args)
16 def __str__(self):
17 s = Exception.__str__(self)
18 if self._dbus_error_name is not None:
19 return '%s: %s' % (self._dbus_error_name, s)
20 else:
21 return s
23 def get_dbus_name(self):
24 return self._dbus_error_name
26 class MissingErrorHandlerException(DBusException):
27 def __init__(self):
28 DBusException.__init__(self, "error_handler not defined: if you define a reply_handler you must also define an error_handler")
30 class MissingReplyHandlerException(DBusException):
31 def __init__(self):
32 DBusException.__init__(self, "reply_handler not defined: if you define an error_handler you must also define a reply_handler")
34 class ValidationException(DBusException):
35 def __init__(self, msg=''):
36 DBusException.__init__(self, "Error validating string: %s"%msg)
38 class IntrospectionParserException(DBusException):
39 def __init__(self, msg=''):
40 DBusException.__init__(self, "Error parsing introspect data: %s"%msg)
42 class UnknownMethodException(DBusException):
43 _dbus_error_name = 'org.freedesktop.DBus.Error.UnknownMethod'
44 def __init__(self, method):
45 DBusException.__init__(self, "Unknown method: %s"%method)
47 class NameExistsException(DBusException):
48 def __init__(self, name):
49 DBusException.__init__(self, "Bus name already exists: %s"%name)