diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/globals.ts | 26 | ||||
-rw-r--r-- | js/libdeno.ts | 10 | ||||
-rw-r--r-- | js/main.ts | 12 |
3 files changed, 22 insertions, 26 deletions
diff --git a/js/globals.ts b/js/globals.ts index 80e00ea15..0364aaf98 100644 --- a/js/globals.ts +++ b/js/globals.ts @@ -1,7 +1,6 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. import { Console } from "./console"; -import { exit } from "./os"; import * as timers from "./timers"; import { TextDecoder, TextEncoder } from "./text_encoding"; import * as fetch_ from "./fetch"; @@ -12,13 +11,6 @@ declare global { interface Window { console: Console; define: Readonly<unknown>; - onerror?: ( - message: string, - source: string, - lineno: number, - colno: number, - error: Error - ) => void; } const clearTimeout: typeof timers.clearTimer; @@ -43,30 +35,12 @@ window.window = window; window.libdeno = null; -// import "./url"; - window.setTimeout = timers.setTimeout; window.setInterval = timers.setInterval; window.clearTimeout = timers.clearTimer; window.clearInterval = timers.clearTimer; window.console = new Console(libdeno.print); -// Uncaught exceptions are sent to window.onerror by the privileged binding. -window.onerror = ( - message: string, - source: string, - lineno: number, - colno: number, - error: Error -) => { - // TODO Currently there is a bug in v8_source_maps.ts that causes a - // segfault if it is used within window.onerror. To workaround we - // uninstall the Error.prepareStackTrace handler. Users will get unmapped - // stack traces on uncaught exceptions until this issue is fixed. - //Error.prepareStackTrace = null; - console.log(error.stack); - exit(1); -}; window.TextEncoder = TextEncoder; window.TextDecoder = TextDecoder; diff --git a/js/libdeno.ts b/js/libdeno.ts index 83dc8efa0..142d779c2 100644 --- a/js/libdeno.ts +++ b/js/libdeno.ts @@ -10,6 +10,16 @@ interface Libdeno { print(x: string): void; + setGlobalErrorHandler: ( + handler: ( + message: string, + source: string, + line: number, + col: number, + error: Error + ) => void + ) => void; + mainSource: string; mainSourceMap: RawSourceMap; } diff --git a/js/main.ts b/js/main.ts index eb90abb0e..51b5790a2 100644 --- a/js/main.ts +++ b/js/main.ts @@ -43,9 +43,21 @@ function onMessage(ui8: Uint8Array) { } } +function onGlobalError( + message: string, + source: string, + lineno: number, + colno: number, + error: Error +) { + console.log(error.stack); + os.exit(1); +} + /* tslint:disable-next-line:no-default-export */ export default function denoMain() { libdeno.recv(onMessage); + libdeno.setGlobalErrorHandler(onGlobalError); const compiler = DenoCompiler.instance(); // First we send an empty "Start" message to let the privlaged side know we |