Re: [webstorage] IndexGetter Methods Should Not Throw Exception

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