mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 512457 - Report errors before they get eaten up by runInBatchMode
Save the exception from inside runBatched and not have runInBatchMode return failure, so we can then expose the exception.
This commit is contained in:
parent
813888cd91
commit
c70241b5ce
@ -93,11 +93,7 @@ BookmarksEngine.prototype = {
|
||||
_storeObj: BookmarksStore,
|
||||
_trackerObj: BookmarksTracker,
|
||||
|
||||
_sync: function BookmarksEngine__sync() {
|
||||
Svc.Bookmark.runInBatchMode({
|
||||
runBatched: Utils.bind2(this, SyncEngine.prototype._sync)
|
||||
}, null);
|
||||
}
|
||||
_sync: Utils.batchSync("Bookmark", SyncEngine)
|
||||
};
|
||||
|
||||
function BookmarksStore() {
|
||||
|
@ -81,11 +81,7 @@ HistoryEngine.prototype = {
|
||||
_storeObj: HistoryStore,
|
||||
_trackerObj: HistoryTracker,
|
||||
|
||||
_sync: function HistoryEngine__sync() {
|
||||
Svc.History.runInBatchMode({
|
||||
runBatched: Utils.bind2(this, SyncEngine.prototype._sync)
|
||||
}, null);
|
||||
},
|
||||
_sync: Utils.batchSync("History", SyncEngine),
|
||||
|
||||
// History reconciliation is simpler than the default one from SyncEngine,
|
||||
// because we have the advantage that we can use the URI as a definitive
|
||||
|
@ -124,6 +124,29 @@ let Utils = {
|
||||
};
|
||||
},
|
||||
|
||||
batchSync: function batchSync(service, engineType) {
|
||||
return function batchedSync() {
|
||||
let engine = this;
|
||||
let batchEx = null;
|
||||
|
||||
// Try running sync in batch mode
|
||||
Svc[service].runInBatchMode({
|
||||
runBatched: function wrappedSync() {
|
||||
try {
|
||||
engineType.prototype._sync.call(engine);
|
||||
}
|
||||
catch(ex) {
|
||||
batchEx = ex;
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
|
||||
// Expose the exception if something inside the batch failed
|
||||
if (batchEx!= null)
|
||||
throw batchEx;
|
||||
};
|
||||
},
|
||||
|
||||
// Generates a brand-new globally unique identifier (GUID).
|
||||
makeGUID: function makeGUID() {
|
||||
let uuidgen = Cc["@mozilla.org/uuid-generator;1"].
|
||||
|
19
services/sync/tests/unit/test_bookmark_batch_fail.js
Normal file
19
services/sync/tests/unit/test_bookmark_batch_fail.js
Normal file
@ -0,0 +1,19 @@
|
||||
_("Making sure a failing sync reports a useful error");
|
||||
Cu.import("resource://weave/engines/bookmarks.js");
|
||||
|
||||
function run_test() {
|
||||
let engine = new BookmarksEngine();
|
||||
engine._syncStartup = function() {
|
||||
throw "FAIL!";
|
||||
};
|
||||
|
||||
try {
|
||||
_("Try calling the sync that should throw right away");
|
||||
engine._sync();
|
||||
do_throw("Should have failed sync!");
|
||||
}
|
||||
catch(ex) {
|
||||
_("Making sure what we threw ended up as the exception:", ex);
|
||||
do_check_eq(ex, "FAIL!");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user