Skip to content

Promise.on.error

David Fahlander edited this page Mar 20, 2015 · 7 revisions

Description

Global exception handler for non-catched promises.

Since Dexie 1.0.4

Subscibe

Dexie.Promise.on("error", globalErrorHandler);

function globalErrorHandler(error) {
    console.error(error);
}

Unsubscribe

Dexie.Promise.on("error").unsubscribe(globalErrorHandler);

Parameters

error: Any Any uncatched error no matter if it was a DB operation or any other non-db operation.

Remarks

This event will fire whenever a Dexie.Promise instance was rejected and not directly catched.

Sample

Dexie.Promise.on("error", function (e) { console.error (e.stack || e); });

new Dexie.Promise(function () {
    throw "Oops!";
});

// promise not catched, so the error will bubble to Dexie.Promise.on('error').
Clone this wiki locally