W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2012

IndexedDB: use of TypeError

From: Alec Flett <alecflett@google.com>
Date: Tue, 29 May 2012 09:49:24 -0700
Message-ID: <CAHWpXeYeeKZtnyvNBVOTim+9WTZQ3vsFCDqHzzTrm3dWT9RtKA@mail.gmail.com>
To: public-webapps@w3.org
So I didn't start working on/implementing indexedDB until after this
message went out:


So I haven't had to face the full implications of using TypeError until
this week.

I'd like to (hopefully not too late) voice my opposition to TypeError for
the following scenarios:

   - invalid value for the 'direction' parameter to open*Cursor (must be
   'next', 'prev', 'nextunique', or 'prevunique')
   - advance(count) where count < 1
   - open(version) where version < 1

The problem here is that these are not easily enforceable by the WebIDL
spec, which means implementations have an extra burden of customizing their
WebIDL implementation to custom-annotate the IDL extend things like
[EnforceRange=Positive] or introducing JS semantics into their otherwise
JS-free code.

Now this certainly could just be an implementors complaint, but I feel like
I can retroactively justify it:

The rationale behind the current spec is that these are very similar to a
"range error" where the API has a very narrow range of values, that precede
any higher level semantic parameter constraints. But the problem is that
they still have some semantic value within IndexedDB - i.e. even though '0'
is a valid numeric value to JavaScript, it is invalid because of specific
consistencies within the IndexedDB spec. Even though "foo" is a valid
string to JavaScript, strings like "next" and "prev" are the only valid
strings because they have specific meaning in the context of IndexedDB.

So I'd argue that these errors should be indexeddb-specific errors, and/or
reused DOMExceptions. What I miss is the NotAllowedError that I believe in
an earlier version of the spec, but I could also believe that
DOMException's InvalidAccessError could also be used ("The object does not
support the operation or argument")

Received on Tuesday, 29 May 2012 16:50:18 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:34 UTC