From 65a2c4b421cd16328a663b2803f1e42bf5bdd180 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 27 May 2018 00:15:52 -0400 Subject: [PATCH] Add onerror handler for uncaught exceptions --- runtime.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/runtime.ts b/runtime.ts index ca7af884cc..52277653f2 100644 --- a/runtime.ts +++ b/runtime.ts @@ -23,6 +23,12 @@ const deno = { pub, sub }; type AmdFactory = (...args: any[]) => undefined | object; type AmdDefine = (deps: string[], factory: AmdFactory) => void; +// Uncaught exceptions are sent to window.onerror by v8worker2. +window.onerror = function(message, source, lineno, colno, error) { + console.log(error.message, error.stack); + os.exit(1); +}; + export function setup(mainJs: string, mainMap: string): void { sourceMaps.install({ installPrepareStackTrace: true,