Bug 87276 - IndexedDB: Align codes and names for IDB-specific and DOM-specific errors/exceptions
Summary: IndexedDB: Align codes and names for IDB-specific and DOM-specific errors/exc...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alec Flett
URL:
Keywords: WebExposed
Depends on:
Blocks:
 
Reported: 2012-05-23 10:14 PDT by Alec Flett
Modified: 2012-06-08 14:58 PDT (History)
10 users (show)

See Also:


Attachments
Patch (27.80 KB, patch)
2012-05-23 10:50 PDT, Alec Flett
no flags Details | Formatted Diff | Diff
Patch (25.58 KB, patch)
2012-05-24 10:33 PDT, Alec Flett
no flags Details | Formatted Diff | Diff
Patch (25.58 KB, patch)
2012-05-24 11:04 PDT, Alec Flett
no flags Details | Formatted Diff | Diff
Patch (25.50 KB, patch)
2012-05-24 16:39 PDT, Alec Flett
no flags Details | Formatted Diff | Diff
Patch (25.51 KB, patch)
2012-05-25 14:28 PDT, Alec Flett
no flags Details | Formatted Diff | Diff
Patch (25.47 KB, patch)
2012-05-29 10:22 PDT, Alec Flett
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alec Flett 2012-05-23 10:14:58 PDT
IndexedDB: Align codes and names for IDB-specific and DOM-specific errors/exceptions
Comment 1 Alec Flett 2012-05-23 10:50:15 PDT
Created attachment 143595 [details]
Patch
Comment 2 WebKit Review Bot 2012-05-23 10:52:11 PDT
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI.
Comment 3 Alec Flett 2012-05-23 10:55:37 PDT
jsbell@, dgrogan@ mind taking a look - this patch is entirely about teasing out system (DOM) exception/error codes from IDB-specific exception codes, and providing a hook to let DOM exceptions have IDB-specific error messages:
http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#exceptions

All of the legacy constants hang off of IDBDatabaseException (as they do today)- and I'm introducing new constants because I've added name constants to avoid some of the issues we hit with the IDBCursor.NEXT/etc landing - in case someone does something like:

if (IDBDatabaseException[exception.name] == IDBDatabaseException.VERSION_ERR)

which is admittedly kind of a degenerate case, but it's mostly defensive.
Comment 4 Joshua Bell 2012-05-23 11:50:34 PDT
Comment on attachment 143595 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=143595&action=review

> LayoutTests/storage/indexeddb/constants-expected.txt:8
> +PASS IDBDatabaseException.UnknownError is 1

My understanding of the spec is that IDBDatabaseException goes away completely, and that exceptions are all DOMExceptions thrown by name. Is there any benefit in introducing IDBDatabaseException.UnknownError (new name) if we are only keeping IDBDatabaseException.UNKNOWN_ERR for compatibility?
Comment 5 Alec Flett 2012-05-23 15:13:05 PDT
Comment on attachment 143595 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=143595&action=review

>> LayoutTests/storage/indexeddb/constants-expected.txt:8
>> +PASS IDBDatabaseException.UnknownError is 1
> 
> My understanding of the spec is that IDBDatabaseException goes away completely, and that exceptions are all DOMExceptions thrown by name. Is there any benefit in introducing IDBDatabaseException.UnknownError (new name) if we are only keeping IDBDatabaseException.UNKNOWN_ERR for compatibility?

It's there entirely for backwards compatibility - if APIs were previously looking at the exception's name field.

See my previous comment in the bug
Comment 6 Joshua Bell 2012-05-23 15:32:02 PDT
(In reply to comment #5)
> It's there entirely for backwards compatibility - if APIs were previously looking at the exception's name field.
> 
> See my previous comment in the bug

Ah, yes, sorry - the "degenerate case". For me, that falls below the threshold for compat support. IMHO we should break those now than add extra surface area to the API to support them.
Comment 7 Alec Flett 2012-05-23 15:56:07 PDT
sounds fine to me..new patch comin' up
Comment 8 Alec Flett 2012-05-24 10:33:10 PDT
Created attachment 143846 [details]
Patch
Comment 9 Early Warning System Bot 2012-05-24 10:55:03 PDT
Comment on attachment 143846 [details]
Patch

Attachment 143846 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/12807166
Comment 10 Alec Flett 2012-05-24 11:04:55 PDT
Created attachment 143852 [details]
Patch
Comment 11 Alec Flett 2012-05-24 12:17:06 PDT
ok jsbell@ ready for review again - removed the "new legacy" constants...
Comment 12 Joshua Bell 2012-05-24 14:57:23 PDT
Comment on attachment 143852 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=143852&action=review

> Source/WebCore/ChangeLog:11
> +        The IDB spec has evolved to MixedCase, string-based style names

I'd explicitly mention "DOM4-style DOMExceptions" here as a keyword for people to look for.

> Source/WebCore/Modules/indexeddb/IDBDatabaseException.cpp:38
>      const char* const name;

MAYBE:  in DOM4 parlance this is now |type| (per http://www.w3.org/TR/dom/#exception-domexception) - rename? (probably save that for later)

> Source/WebCore/Modules/indexeddb/IDBDatabaseException.cpp:40
> +    const ExceptionCode domCode;

Suggest just |code| instead of |domCode| which matches http://www.w3.org/TR/dom/#exception-domexception - or maybe |legacyCode|

> Source/WebCore/Modules/indexeddb/IDBDatabaseException.cpp:42
> +    { "UnknownError", "An unknown error occurred within Indexed Database.", 0 },

Add a comment that these names/descriptions are from the spec and are IDB specific

> Source/WebCore/Modules/indexeddb/IDBDatabaseException.cpp:51
> +    { "NotFoundError", "An operation failed because the requested database object could not be found.", NOT_FOUND_ERR },

Add  a comment that these are standard DOM4 exception names, but have IDB-specific descriptions

> Source/WebCore/Modules/indexeddb/IDBDatabaseException.h:48
>          NON_TRANSIENT_ERR,

Add a FIXME that NON_TRANSIENT_ERR will be removed (no longer in IDB spec)

> Source/WebCore/Modules/indexeddb/IDBDatabaseException.h:51
>          NOT_ALLOWED_ERR,

Add a FIXME that NOT_ALLOWED_ERR will be removed (no longer in IDB spec)

> Source/WebCore/Modules/indexeddb/IDBDatabaseException.idl:45
> +        const unsigned short CONSTRAINT_ERR = 3;

This renumbering may break code that has hardcoded the number (e.g. via Closure compiler). Should we keep the legacy numbers intact until we actually remove IDBDatabaseException? Would require dummy entries in the C++ code.
Comment 13 Alec Flett 2012-05-24 16:39:00 PDT
Created attachment 143922 [details]
Patch
Comment 14 Alec Flett 2012-05-25 11:54:45 PDT
jsbell@ - ping - hopefully this is just a rubber stamp at this point, comments have been addressed.

(I have another patch coming up which is dependent on this and has more extensive tests too)
Comment 15 Joshua Bell 2012-05-25 11:56:37 PDT
Comment on attachment 143922 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=143922&action=review

lgtm with nit

> Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:216
> +        // FIXME: IDBDatabaseError doesn't yet do proper translation of IDB-specifc uses of error codes, this should be IDB_ABORT_ERR

Typo: "specifc" -> "specific"
Comment 16 Alec Flett 2012-05-25 14:28:52 PDT
Created attachment 144147 [details]
Patch
Comment 17 Alec Flett 2012-05-29 10:22:49 PDT
Created attachment 144582 [details]
Patch
Comment 18 Alec Flett 2012-05-29 10:23:32 PDT
tony@ - r? cq?
Comment 19 Tony Chang 2012-05-29 11:41:27 PDT
Comment on attachment 144582 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=144582&action=review

> Source/WebCore/Modules/indexeddb/IDBDatabaseException.cpp:45
> +    { "NonTransientError", "NonTransientError", 0 }, // FIXME: No longer in the spec
> +    { 0, 0, 0 }, // FIXME: Previous/legacy value NOT_FOUND_ERR.

Keeping parallel arrays seems fragile.  Are there plans to move away from this?  E.g., maybe we could use a map or a static sized array where we assign each entry based on the enum values.
Comment 20 Alec Flett 2012-05-29 11:46:09 PDT
Totally agree on parallel arrays, it's very fragile - this happens to be getting a lot of attention right now (read: 2-3 more patches this week against it) so it will stay in sync but long term we'll be moving away from that to a map...
Comment 21 WebKit Review Bot 2012-05-29 14:20:47 PDT
Comment on attachment 144582 [details]
Patch

Clearing flags on attachment: 144582

Committed r118835: <http://trac.webkit.org/changeset/118835>
Comment 22 WebKit Review Bot 2012-05-29 14:20:53 PDT
All reviewed patches have been landed.  Closing bug.