W3C home > Mailing lists > Public > public-device-apis@w3.org > September 2009

Re: ISSUE-2 (error-handling): Error handling style [APIs General]

From: Robin Berjon <robin@berjon.com>
Date: Tue, 1 Sep 2009 15:42:58 +0200
Cc: "Arve Bersvendsen" <arveb@opera.com>, "Device APIs and Policy Working Group WG" <public-device-apis@w3.org>
Message-Id: <D53EA672-9926-4109-AB64-A37EF33268AF@berjon.com>
To: Anne van Kesteren <annevk@opera.com>
On Sep 1, 2009, at 11:44 , Anne van Kesteren wrote:
> On Tue, 01 Sep 2009 11:36:12 +0200, Robin Berjon <robin@berjon.com>  
> wrote:
>> In other words I'm not saying it's necessarily the hardest, most  
>> technical of debates, just that it needs to be decided. Strawmen  
>> and proposals welcome.
>
> I'd like to argue for not having a common style. Different problems  
> require different APIs and different APIs require different kind of  
> error handling.

Sorry if I was unclear, the idea is not to define ex nihilo one single  
style to be brutally applied in all cases. I don't think anyone wants  
a straightjacket here. What I had in mind was more along the lines of  
rules of thumb that we can point to to avoid excessive future debate.  
In fact, you go on to list pretty much the sort of stuff that I had in  
mind:

> If a problem requires an event driven API you'd use an error event  
> perhaps with an appropriate interface. If a problem requires a  
> callback API you'd use an additional argument that gets called with  
> an error object. If you have a synchronous API of some sorts to be  
> used within Web Workers you'd use exceptions. You'd also use  
> exceptions in case the "API object" can be in different states and a  
> method gets called in the wrong state. Or when a method gets invoked  
> with an argument that doesn't meet expectations (e.g. an invalid URL).

That looks like a pretty good start to me. There are a few other  
questions such as BONDI's interface versus exception thing but if  
people agree with the above I don't think we need much more.

-- 
Robin Berjon - http://berjon.com/
Received on Tuesday, 1 September 2009 13:43:39 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 14:53:38 UTC