Permalink
Browse files

Updating goog.db to comply with the latest specs regarding error repo…

…rting.

See http://www.w3.org/TR/IndexedDB/#exceptions

Errors used to be reported as numerical error codes. Now they are reported
as strings. Chrome25 is the first version that is not backward compatible.
Chrome 22, 23, 24 support both.

R=nweiz
DELTA=328 (215 added, 20 deleted, 93 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=6247


git-svn-id: http://closure-library.googlecode.com/svn/trunk@2501 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
1 parent 3b34e61 commit 53996fb0c6f14eba3df063ac0202e6d65f9138ea dpapad@google.com committed Feb 2, 2013
View
@@ -86,16 +86,15 @@ goog.db.Cursor.prototype.update = function(value) {
request = this.cursor_.update(value);
} catch (err) {
msg += goog.debug.deepExpose(value);
- d.errback(goog.db.Error.create(err, msg));
+ d.errback(goog.db.Error.fromException(err, msg));
return d;
}
request.onsuccess = function(ev) {
d.callback();
};
request.onerror = function(ev) {
msg += goog.debug.deepExpose(value);
- d.errback(new goog.db.Error(
- (/** @type {IDBRequest} */ (ev.target)).errorCode, msg));
+ d.errback(goog.db.Error.fromRequest(ev.target, msg));
};
return d;
};
@@ -115,15 +114,14 @@ goog.db.Cursor.prototype.remove = function() {
try {
request = this.cursor_['delete']();
} catch (err) {
- d.errback(goog.db.Error.create(err, msg));
+ d.errback(goog.db.Error.fromException(err, msg));
return d;
}
request.onsuccess = function(ev) {
d.callback();
};
request.onerror = function(ev) {
- d.errback(new goog.db.Error(
- (/** @type {IDBRequest} */ (ev.target)).errorCode, msg));
+ d.errback(goog.db.Error.fromRequest(ev.target, msg));
};
return d;
};
View
@@ -133,7 +133,7 @@ goog.db.openDatabase = function(name, opt_version, opt_onUpgradeNeeded,
};
openRequest.onerror = function(ev) {
var msg = 'opening database ' + name;
- d.errback(new goog.db.Error(ev.target.errorCode, msg));
+ d.errback(goog.db.Error.fromRequest(ev.target, msg));
};
openRequest.onupgradeneeded = function(ev) {
if (!opt_onUpgradeNeeded) return;
@@ -170,7 +170,7 @@ goog.db.deleteDatabase = function(name, opt_onBlocked) {
};
deleteRequest.onerror = function(ev) {
var msg = 'deleting database ' + name;
- d.errback(new goog.db.Error(ev.target.errorCode, msg));
+ d.errback(goog.db.Error.fromRequest(ev.target, msg));
};
deleteRequest.onblocked = function(ev) {
if (opt_onBlocked) {
Oops, something went wrong.

0 comments on commit 53996fb

Please sign in to comment.