summaryrefslogtreecommitdiff
path: root/js/globals.ts
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-08-22 17:17:26 -0400
committerGitHub <noreply@github.com>2018-08-22 17:17:26 -0400
commite7cab715749e4c5000c24ffeade1ef915d15a68d (patch)
tree3ddb749342a415112f3bf4b1f3aa7156dca9c8af /js/globals.ts
parentc5bb412933d750c80c93eaa4840eb3bbac33bc2c (diff)
runtime.ts refactor into compiler.ts (#564)
Adds compiler_test.ts
Diffstat (limited to 'js/globals.ts')
-rw-r--r--js/globals.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/js/globals.ts b/js/globals.ts
index ebfd3d265..beecbf58d 100644
--- a/js/globals.ts
+++ b/js/globals.ts
@@ -1,6 +1,7 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
import { Console } from "./console";
+import { exit } from "./os";
import { RawSourceMap } from "./types";
import * as timers from "./timers";
import { TextEncoder, TextDecoder } from "./text_encoding";
@@ -9,6 +10,14 @@ import * as fetch_ from "./fetch";
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;
@@ -58,6 +67,22 @@ 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;