Errors and the introspection format

Matthew Johnson dbus at
Sun Feb 19 11:20:04 PST 2006

On Sun, 19 Feb 2006, Havoc Pennington wrote:

> On Sun, 2006-02-19 at 18:35 +0000, Matthew Johnson wrote:
>> I just think that the introspection format should contain what
>> exceptions I should be looking out for. It makes my life easier in both
>> Java and other languages if they are written down next to the function
>> definition. An annotation is fine, it doesn't need to be the formal type
>> of the function, but it should be there.
> You aren't addressing any of the points I'm bringing up, though. If you
> just want to know what you're looking out for, then I've proposed a
> couple things that will help:
> - put the exceptions in the docs introspection data, alongside
>   docstrings however we do those

I was suggesting a separate annotation for the throws, but is otherwise

> - globally list exceptions that should have a mapping to a class,
> so you can use them in a catch() block

Yup, this is essentially what I want.

> The only additional thing you can do is have _checked_ exceptions that
> get declared in a Java throws clause, and that is not the same as
> knowing what exceptions to look out for. That's putting exceptions _in
> the type signature_ of the method, which raises a number of issues that
> we can simply avoid by not doing it.

OK, if you do the above scheme and the Java bindings do:

public void foo() throws bar;

rather than:

public void foo();

is there any problem with this? As far as I can see there are *no*
additional problems with either approach, even with changing APIs.

> The throws clause in the Java bindings should be one of two things:
> - "throws DBusException" where DBusException is checked (pedantically
>   correct approach, like JMSException or InvocationTargetException)
> - no throws clause at all, but @throws DBusException in the docs
>   where DBusException is unchecked (this is what Java RMI does for
>   example, or also comparable to EJBException)
> I prefer the first really, but I think most programmers prefer the
> second.
Yup, so do I.

Matthew Johnson

More information about the dbus mailing list