Errors and the introspection format

Thiago Macieira thiago.macieira at
Fri Feb 17 04:54:37 PST 2006

Matthew Johnson wrote:
>This came up while I was writing the error support in the Java bindings,
>if you call a method that returns an error it throws an exception of the
>type given as the error name. To do this I need to create a class of
>that type, which I can't do automatically if it isn't in the
>introspection data. (you can also throw on if you want to return an
>error from a method implemented on the server).

I don't know how the Java bindings work in this aspect, but I'd suggest 
you use one wrapper "D-Bus error" throwable that can be thrown from any 
method, in case you get an unknown error from a remote program. It might 
even be a superclass for all other D-Bus throwables.

Unlike Java, some other programming languages don't use binding throwables 
(in C++, the default is "I can throw anything"). This means future 
versions of a given interface could change behaviour. I do agree with 
you, though, that, for the freedesktop-defined interfaces, we define what 
they can throw and make it binding.

This would allow users to catch unexpected exceptions when dealing with an 
arbitrary program, but also named or typed exceptions when dealing with a 
well-behaved program.

FYI, the programming practice in Qt and KDE programs is to not use 
exceptions at all, so you may expect that error conditions be returned as 
normal return messages, not error ones.
Thiago José Macieira - thiago.macieira AT
Trolltech AS - Sandakerveien 116, NO-0402 Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url :

More information about the dbus mailing list