From c113df1bb8a0c7d0c560ad32c0291c918c7da7b4 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 6 Dec 2018 23:05:36 -0500 Subject: Process source maps in Rust instead of JS (#1280) - Improves speed and binary size significantly. - Makes deno_last_exception() output a JSON structure. - Isolate::execute and Isolate::event_loop now return structured, mapped JSError objects on errors. - Removes libdeno functions: libdeno.setGlobalErrorHandler() libdeno.setPromiseRejectHandler() libdeno.setPromiseErrorExaminer() In collaboration with Ryan Dahl. --- js/promise_util.ts | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 js/promise_util.ts (limited to 'js/promise_util.ts') diff --git a/js/promise_util.ts b/js/promise_util.ts deleted file mode 100644 index 3c789124d..000000000 --- a/js/promise_util.ts +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2018 the Deno authors. All rights reserved. MIT license. -import { PromiseRejectEvent } from "./libdeno"; - -/* tslint:disable-next-line:no-any */ -const rejectMap = new Map, string>(); -// For uncaught promise rejection errors - -/* tslint:disable-next-line:no-any */ -const otherErrorMap = new Map, string>(); -// For reject after resolve / resolve after resolve errors - -export function promiseRejectHandler( - error: Error | string, - event: PromiseRejectEvent, - /* tslint:disable-next-line:no-any */ - promise: Promise -) { - switch (event) { - case "RejectWithNoHandler": - rejectMap.set(promise, (error as Error).stack || "RejectWithNoHandler"); - break; - case "HandlerAddedAfterReject": - rejectMap.delete(promise); - break; - case "ResolveAfterResolved": - // Should not warn. See #1272 - break; - default: - // error is string here - otherErrorMap.set(promise, `Promise warning: ${error as string}`); - } -} - -// Return true when continue, false to die on uncaught promise reject -export function promiseErrorExaminer(): boolean { - if (otherErrorMap.size > 0) { - for (const msg of otherErrorMap.values()) { - console.log(msg); - } - otherErrorMap.clear(); - } - if (rejectMap.size > 0) { - for (const msg of rejectMap.values()) { - console.log(msg); - } - rejectMap.clear(); - return false; - } - return true; -} -- cgit v1.2.3