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

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

From: Anne van Kesteren <annevk@opera.com>
Date: Tue, 01 Sep 2009 11:44:57 +0200
To: "Robin Berjon" <robin@berjon.com>, "Arve Bersvendsen" <arveb@opera.com>
Cc: "Device APIs and Policy Working Group WG" <public-device-apis@w3.org>
Message-ID: <op.uzkn070g64w2qv@annevk-t60>
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. 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).

I think the easy answer to error handling is figuring out what API is best  
for solving the problem at hand and then looking at prior art.

Anne van Kesteren
Received on Tuesday, 1 September 2009 09:46:14 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:32:11 UTC