mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 02:22:40 +00:00
refactor: add and use libdeno.setGlobalErrorHandler instead of window.onerror
This commit is contained in:
parent
3a5cf9ca8b
commit
17d6d6b336
7 changed files with 88 additions and 56 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue