This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 17643 - What should transaction.error be set to if a error handler throws an exception
Summary: What should transaction.error be set to if a error handler throws an exception
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: Indexed Database API (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-28 22:22 UTC by Jonas Sicking (Not reading bugmail)
Modified: 2012-07-15 09:20 UTC (History)
3 users (show)

See Also:


Attachments

Description Jonas Sicking (Not reading bugmail) 2012-06-28 22:22:25 UTC
The most basic question is, what should happen in the following scenario:

objectStore.add("value", 1); // succeeds
req = objectStore.add("value", 1); // will fail due to key collision
req.onerror = function(e) {
  throw;
}

This should obviously abort the transaction, but should transaction.error.name return "ConstraintError" or "AbortError".

I don't have a strong opinion.

It sort of feels like the exception does override normal behavior, so we should set it to "AbortError".
Comment 1 Jonas Sicking (Not reading bugmail) 2012-06-28 22:23:19 UTC
A slightly less ambiguous case is

objectStore.add("value", 1); // succeeds
req = objectStore.add("value", 1); // will fail due to key collision
req.onerror = function(e) {
  e.preventDefault();
  throw;
}


Here it seems more clear that setting transaction.error to a "AbortError" is the right thing to do.
Comment 2 Jonas Sicking (Not reading bugmail) 2012-06-28 22:43:07 UTC
One way to look at it is that for a normal function call, an exception overrides any return values.
Comment 3 Odin Hørthe Omdal 2012-07-03 16:24:15 UTC
If I was writing a test for that, I'd check for AbortError. So guess I vote for that.


(The exception inside a handler has consequences stuff always felt a bit weird, tho ;-) )
Comment 4 Jonas Sicking (Not reading bugmail) 2012-07-15 09:20:58 UTC
http://dvcs.w3.org/hg/IndexedDB/rev/aab14b0951ca