Skip to content

Commit

Permalink
update error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
ksyeo1010 committed Oct 26, 2023
1 parent e650373 commit dc8c41d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion binding/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Porcupine wake word engine for web browsers (via WebAssembly)",
"author": "Picovoice Inc",
"license": "Apache-2.0",
"version": "3.0.0",
"version": "3.0.1",
"keywords": [
"porcupine",
"web",
Expand Down
20 changes: 14 additions & 6 deletions binding/web/src/porcupine_worker_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,20 @@ self.onmessage = async function(
sampleRate: porcupine.sampleRate,
});
} catch (e: any) {
self.postMessage({
command: 'error',
status: PvStatus.RUNTIME_ERROR,
shortMessage: e.shortMessage,
messageStack: e.messageStack
});
if (e instanceof PorcupineError) {
self.postMessage({
command: 'error',
status: e.status,
shortMessage: e.shortMessage,
messageStack: e.messageStack
});
} else {
self.postMessage({
command: 'error',
status: PvStatus.RUNTIME_ERROR,
shortMessage: e.message
});
}
}
break;
case 'process':
Expand Down

0 comments on commit dc8c41d

Please sign in to comment.