Encode op errors as strings instead of numbers (#6977)

This commit is contained in:
Bartek Iwańczuk 2020-08-07 22:47:18 +02:00 committed by GitHub
parent 479164d287
commit 59ca66a207
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 197 additions and 293 deletions

View file

@ -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");
}