From 24411ac18fa04c5560aa625b937824cef2f9c62f Mon Sep 17 00:00:00 2001 From: lana-k Date: Sat, 24 Apr 2021 16:53:19 +0200 Subject: [PATCH] fix error handling for web worker in Firefox #27 --- src/database.js | 6 +++--- src/db.worker.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/database.js b/src/database.js index 95e184a..45eb25b 100644 --- a/src/database.js +++ b/src/database.js @@ -59,7 +59,7 @@ class Database { }) if (result.error) { - throw result.error + throw new Error(result.error) } return await this.getSchema(name) @@ -70,7 +70,7 @@ class Database { const res = await this.pw.postMessage({ action: 'open', buffer: fileContent }) if (res.error) { - throw res.error + throw new Error(res.error) } return this.getSchema(file.name) @@ -103,7 +103,7 @@ class Database { const results = await this.pw.postMessage({ action: 'exec', sql: commands }) if (results.error) { - throw results.error + throw new Error(results.error) } // if it was more than one select - take only the last one return results[results.length - 1] diff --git a/src/db.worker.js b/src/db.worker.js index 7493889..3395468 100644 --- a/src/db.worker.js +++ b/src/db.worker.js @@ -23,7 +23,7 @@ function processMsg (sql) { function onError (error) { return { - error + error: error.message } }