-
-
Notifications
You must be signed in to change notification settings - Fork 641
DexieError
David Fahlander edited this page Oct 12, 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.
-
Error
- SyntaxError
- TypeError
- Dexie.DexieError
- Dexie.AbortError
- Dexie.BulkError
- Dexie.ConstraintError
- Dexie.DatabaseClosedError
- Dexie.DataCloneError
- Dexie.DataError
- Dexie.IncompatiblePromiseError
- Dexie.InternalError
- Dexie.InvalidAccessError
- Dexie.InvalidArgumentError
- Dexie.InvalidStateError
- Dexie.InvalidTableError
- Dexie.MissingAPIError
- Dexie.ModifyError
- Dexie.NoSuchDatabaseError
- Dexie.NotFoundError
- Dexie.OpenFailedError
- Dexie.QuotaExceededError
- Dexie.PrematureCommitError
- Dexie.ReadOnlyError
- Dexie.SchemaError
- Dexie.SubTransactionError
- Dexie.TimeoutError
- Dexie.TransactionInactiveError
- Dexie.UnknownError
- Dexie.UnsupportedError
- Dexie.InternalError
- Dexie.DatabaseClosedError
- Dexie.IncompatiblePromiseError (Obsolete since v2.0.0)
- Dexie.UnknownError
- Dexie.ConstraintError
- Dexie.DataError
- Dexie.TransactionInactiveError
- Dexie.ReadOnlyError
- Dexie.VersionError
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 catched: " + 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);
}
});
name: string | Name of the error |
message: string | Detailed message |
inner?: any | Inner exception instance (if any) |
stack?: string | Can be present if the error was thown. If signaled, there wont be any call stack. |
If explicitely catching an error, the ongoing transaction will NOT abort. If that is not your desire, for example if you are just catching the error for logging purpose, you should rethrow the error after logging it.
The catch effect also applies when using yield or async / await and a standard try..catch.
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.
});
});
Dexie.js - minimalistic and bullet proof indexedDB library