summaryrefslogtreecommitdiff
path: root/cli/tsc
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tsc')
-rw-r--r--cli/tsc/01_errors.js96
-rw-r--r--cli/tsc/10_dispatch_json.js4
-rw-r--r--cli/tsc/99_main_compiler.js22
3 files changed, 24 insertions, 98 deletions
diff --git a/cli/tsc/01_errors.js b/cli/tsc/01_errors.js
index 8390dd803..fb2bb78c2 100644
--- a/cli/tsc/01_errors.js
+++ b/cli/tsc/01_errors.js
@@ -1,101 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
((window) => {
- // Warning! The values in this enum are duplicated in cli/op_error.rs
- // Update carefully!
- const ErrorKind = {
- 1: "NotFound",
- 2: "PermissionDenied",
- 3: "ConnectionRefused",
- 4: "ConnectionReset",
- 5: "ConnectionAborted",
- 6: "NotConnected",
- 7: "AddrInUse",
- 8: "AddrNotAvailable",
- 9: "BrokenPipe",
- 10: "AlreadyExists",
- 13: "InvalidData",
- 14: "TimedOut",
- 15: "Interrupted",
- 16: "WriteZero",
- 17: "UnexpectedEof",
- 18: "BadResource",
- 19: "Http",
- 20: "URIError",
- 21: "TypeError",
- 22: "Other",
- 23: "Busy",
-
- NotFound: 1,
- PermissionDenied: 2,
- ConnectionRefused: 3,
- ConnectionReset: 4,
- ConnectionAborted: 5,
- NotConnected: 6,
- AddrInUse: 7,
- AddrNotAvailable: 8,
- BrokenPipe: 9,
- AlreadyExists: 10,
- InvalidData: 13,
- TimedOut: 14,
- Interrupted: 15,
- WriteZero: 16,
- UnexpectedEof: 17,
- BadResource: 18,
- Http: 19,
- URIError: 20,
- TypeError: 21,
- Other: 22,
- Busy: 23,
- };
-
- function getErrorClass(kind) {
- switch (kind) {
- case ErrorKind.TypeError:
- return TypeError;
- case ErrorKind.Other:
- return Error;
- case ErrorKind.URIError:
- return URIError;
- case ErrorKind.NotFound:
- return NotFound;
- case ErrorKind.PermissionDenied:
- return PermissionDenied;
- case ErrorKind.ConnectionRefused:
- return ConnectionRefused;
- case ErrorKind.ConnectionReset:
- return ConnectionReset;
- case ErrorKind.ConnectionAborted:
- return ConnectionAborted;
- case ErrorKind.NotConnected:
- return NotConnected;
- case ErrorKind.AddrInUse:
- return AddrInUse;
- case ErrorKind.AddrNotAvailable:
- return AddrNotAvailable;
- case ErrorKind.BrokenPipe:
- return BrokenPipe;
- case ErrorKind.AlreadyExists:
- return AlreadyExists;
- case ErrorKind.InvalidData:
- return InvalidData;
- case ErrorKind.TimedOut:
- return TimedOut;
- case ErrorKind.Interrupted:
- return Interrupted;
- case ErrorKind.WriteZero:
- return WriteZero;
- case ErrorKind.UnexpectedEof:
- return UnexpectedEof;
- case ErrorKind.BadResource:
- return BadResource;
- case ErrorKind.Http:
- return Http;
- case ErrorKind.Busy:
- return Busy;
- }
- }
-
class NotFound extends Error {
constructor(msg) {
super(msg);
@@ -245,6 +150,5 @@
window.__bootstrap.errors = {
errors,
- getErrorClass,
};
})(this);
diff --git a/cli/tsc/10_dispatch_json.js b/cli/tsc/10_dispatch_json.js
index 3d19ea62a..a25014789 100644
--- a/cli/tsc/10_dispatch_json.js
+++ b/cli/tsc/10_dispatch_json.js
@@ -3,7 +3,7 @@
((window) => {
const core = window.Deno.core;
const util = window.__bootstrap.util;
- const getErrorClass = window.__bootstrap.errors.getErrorClass;
+
// Using an object without a prototype because `Map` was causing GC problems.
const promiseTable = Object.create(null);
let _nextPromiseId = 1;
@@ -22,7 +22,7 @@
function unwrapResponse(res) {
if (res.err != null) {
- throw new (getErrorClass(res.err.kind))(res.err.message);
+ throw new (core.getErrorClass(res.err.kind))(res.err.message);
}
util.assert(res.ok != null);
return res.ok;
diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js
index 41051f2e0..23e25237a 100644
--- a/cli/tsc/99_main_compiler.js
+++ b/cli/tsc/99_main_compiler.js
@@ -23,6 +23,7 @@ delete Object.prototype.__proto__;
const dispatchJson = window.__bootstrap.dispatchJson;
const util = window.__bootstrap.util;
const errorStack = window.__bootstrap.errorStack;
+ const errors = window.__bootstrap.errors.errors;
function opNow() {
const res = dispatchJson.sendSync("op_now");
@@ -1851,6 +1852,27 @@ delete Object.prototype.__proto__;
throw new Error("Worker runtime already bootstrapped");
}
hasBootstrapped = true;
+ core.registerErrorClass("NotFound", errors.NotFound);
+ core.registerErrorClass("PermissionDenied", errors.PermissionDenied);
+ core.registerErrorClass("ConnectionRefused", errors.ConnectionRefused);
+ core.registerErrorClass("ConnectionReset", errors.ConnectionReset);
+ core.registerErrorClass("ConnectionAborted", errors.ConnectionAborted);
+ core.registerErrorClass("NotConnected", errors.NotConnected);
+ core.registerErrorClass("AddrInUse", errors.AddrInUse);
+ core.registerErrorClass("AddrNotAvailable", errors.AddrNotAvailable);
+ core.registerErrorClass("BrokenPipe", errors.BrokenPipe);
+ core.registerErrorClass("AlreadyExists", errors.AlreadyExists);
+ core.registerErrorClass("InvalidData", errors.InvalidData);
+ core.registerErrorClass("TimedOut", errors.TimedOut);
+ core.registerErrorClass("Interrupted", errors.Interrupted);
+ core.registerErrorClass("WriteZero", errors.WriteZero);
+ core.registerErrorClass("UnexpectedEof", errors.UnexpectedEof);
+ core.registerErrorClass("BadResource", errors.BadResource);
+ core.registerErrorClass("Http", errors.Http);
+ core.registerErrorClass("URIError", URIError);
+ core.registerErrorClass("TypeError", TypeError);
+ core.registerErrorClass("Other", Error);
+ core.registerErrorClass("Busy", errors.Busy);
globalThis.__bootstrap = undefined;
runtimeStart("TS");
}