1 """D-Bus exceptions."""
3 __all__
= ('DBusException', 'MissingErrorHandlerException',
4 'MissingReplyHandlerException', 'ValidationException',
5 'IntrospectionParserException', 'UnknownMethodException',
8 class DBusException(Exception):
9 def __init__(self
, *args
, **kwargs
):
10 self
._dbus
_error
_name
= kwargs
.pop('name', None)
12 raise TypeError('DBusException does not take keyword arguments: %s'
13 % ', '.join(kwargs
.keys()))
14 Exception.__init
__(self
, *args
)
17 s
= Exception.__str
__(self
)
18 if self
._dbus
_error
_name
is not None:
19 return '%s: %s' % (self
._dbus
_error
_name
, s
)
23 def get_dbus_name(self
):
24 return self
._dbus
_error
_name
26 class MissingErrorHandlerException(DBusException
):
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
):
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
)