Database exception handling

This commit is contained in:
Mo Bitar
2020-03-25 22:04:14 -05:00
parent a80a94de5e
commit 9d6c32890a
6 changed files with 96 additions and 98 deletions

View File

@@ -104,7 +104,7 @@ export class Database {
/** @access public */
async getAllPayloads() {
const db = await this.openDatabase();
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
const objectStore =
db.transaction(STORE_NAME).
objectStore(STORE_NAME);
@@ -170,11 +170,11 @@ export class Database {
/** @access public */
async deletePayload(uuid) {
const db = await this.openDatabase();
const request =
db.transaction(STORE_NAME, READ_WRITE)
.objectStore(STORE_NAME)
.delete(uuid);
return new Promise((resolve, reject) => {
const request =
db.transaction(STORE_NAME, READ_WRITE)
.objectStore(STORE_NAME)
.delete(uuid);
request.onsuccess = resolve;
request.onerror = reject;
});