DexieError
class DexieError extends Error {}Inheritance Hierarchy
Sample
Sample: switch(error.name)
Properties
name: string
Name of the error
class DexieError extends Error {}doSomeDatabaseWork().then(function(){
//
// Success
//
}).catch('ModifyError', function (e) {
//
// Failed with ModifyError. Check out e.failures
//
console.error ("ModifyError occurred: " + e.failures.length + " failures"); +
}).catch('ConstraintError', function (e) {
//
// Failed with ConstraintError
//
console.error ("Error: " + e.message);
}).catch(function (e) {
//
// Other error such as a string was thrown
//
console.error ("Other unknown error caught: " + e);
});doSomeDatabaseWork().then(function(){
// Success
}).catch(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;
case ...
default:
console.error ("error: " + e);
}
});db.transaction('rw', db.friends, function() {
db.friends.add({id: 1, name: "Orvar", age: 3}).catch(function (e) {
console.error ("Could not add Orvar");
throw e; // Rethrowing so that transaction is indeed aborted.
});
});
// Or with yield
db.transaction('rw', db.friends, function*() {
try {
yield db.friends.add({id: 1, name: "Orvar", age: 3});
} catch (e) {
console.error ("Could not add Orvar");
throw e; // Rethrowing so that transaction is indeed aborted.
});
});