sql.js icon indicating copy to clipboard operation
sql.js copied to clipboard

WASM error cod if not loading (not working worker.onerror)

Open zirill opened this issue 5 years ago • 2 comments

How to catch the error, not loading the WASM file?

For example: if it is blocked - an ad blocker.

PS: not working worker.onerror in wasm

zirill avatar May 11 '19 02:05 zirill

http://kripken.github.io/sql.js/examples/GUI/

Test code error: CREATE TABLE test;

Console: worker.sql-wasm.js:82 Uncaught (in promise) Error: near ";": syntax error at a.handleError (worker.sql-wasm.js:82) at a.exec (worker.sql-wasm.js:79) at worker.sql-wasm.js:243

PS: event onerror not working

zirill avatar May 19 '19 11:05 zirill

my bad decision:

Database.prototype.handleError = function (returnCode) { var errmsg; if (returnCode === SQLite.OK) { return null; } else { errmsg = sqlite3_errmsg(this.db); setTimeout(function() { throw new Error(errmsg); }); throw new Error(errmsg); } };

https://stackoverflow.com/questions/39992417/how-to-bubble-a-web-worker-error-in-a-promise-via-worker-onerror

zirill avatar May 19 '19 12:05 zirill