Skip to content

DexieError

David Fahlander edited this page Mar 15, 2016 · 28 revisions

since v.1.3.3

class DexieError extends Error {}

Acts as the base class for exceptions that can be returned in rejected Dexie promises.

Inheritance Hierarchy

Sample

doSomeDatabaseWork().then(function(){
    // Success
}).catch(Dexie.ModifyError, function (e) {
    // Failed with ModifyError. Check out e.failures
    console.error ("ModifyError occurred: " + e.failures.length +
     " failures and " + e.successCount + " successful operations");
}).catch(Dexie.DexieError, funtion (e) {
    // Any other Dexie related error occurred
    console.error ("Error: " + e.message);
}).catch(funtion (e) {
    // Other error such as a string was thrown
    console.error (e);
});

Sample: switch(error.name)

db.on('error', function (error) {
    switch (error.name) {
        case "UpgradeError": // or case Dexie.errnames.Upgrade: ...
            console.error ("Upgrade error");
            break;
        case "ModifyError": // or case Dexie.errnames.Modify: ...
            console.error ("Modify error");
            break;
        default:
            console.error ("error: " + e);
    }
});

Properties

name Name of the error
message Detailed message
inner? Inner exception instance (if any)
stack Can be present if the error was thown. If signaled, there wont be any call stack.
Clone this wiki locally