Skip to content

Commit b233e61

Browse files
bryangingechenlovasoa
authored andcommitted
fix error-handling in worker, tweak example (#288)
1 parent e810a2c commit b233e61

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

examples/GUI/gui.js

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ function execute(commands) {
3232
worker.onmessage = function (event) {
3333
var results = event.data.results;
3434
toc("Executing SQL");
35+
if (!results) {
36+
error({message: event.data.error});
37+
return;
38+
}
3539

3640
tic();
3741
outputElm.innerHTML = "";

src/worker.coffee

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@ if typeof importScripts is 'function' # Detect webworker context
4848
when 'close'
4949
db?.close()
5050
else
51-
throw new 'Invalid action : ' + data?['action']
51+
throw new Error 'Invalid action : ' + data?['action']
52+
.catch (err) ->
53+
postMessage
54+
'id': event['data']['id']
55+
'error': err['message']

0 commit comments

Comments
 (0)