W3C home > Mailing lists > Public > public-html@w3.org > July 2009

Re: [webstorage] IndexGetter Methods Should Not Throw Exception

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 1 Jul 2009 04:43:31 +0000 (UTC)
To: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Cc: public-html <public-html@w3.org>
Message-ID: <Pine.LNX.4.62.0907010439490.1060@hixie.dreamhostps.com>
On Fri, 5 Jun 2009, Lachlan Hunt wrote:
> The IndexGetter methods for both the Storage interface (key(index)) and 
> the SQLResultSetRowList interface (item(index)) are currently defined to 
> thrown an INDEX_SIZE_ERR when the index is out of bounds.
> For the following reasons, the spec should instead say that null should 
> be returned instead.
> * Consistency with other DOM APIs, such as NodeList.item()

Ok. This still leaves the TimeRanges.start() and .end() methods and the 
Selection.getRangeAt() methods, which throw exceptions in this case, but 
other than that I think everything returns null.

> * Doesn't require authors to use try/catch blocks to catch unexpected
>   errors.

Throwing an exception doesn't either. They can just compare the index 
they're about to use against the length.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Wednesday, 1 July 2009 04:44:07 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:44:50 UTC