mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00
refactor(cli/js): Replace constructError() with getErrorClass() (#4189)
Flattens dispatch error handling to produce one less useless stack frame on op errors.
This commit is contained in:
parent
f55b22e195
commit
1f9d158bdc
10 changed files with 32 additions and 39 deletions
|
@ -3,7 +3,7 @@ import * as util from "./util.ts";
|
|||
import { TextEncoder, TextDecoder } from "./text_encoding.ts";
|
||||
import { core } from "./core.ts";
|
||||
import { OPS_CACHE } from "./runtime.ts";
|
||||
import { ErrorKind, constructError } from "./errors.ts";
|
||||
import { ErrorKind, getErrorClass } from "./errors.ts";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type Ok = any;
|
||||
|
@ -38,7 +38,7 @@ function encode(args: object): Uint8Array {
|
|||
|
||||
function unwrapResponse(res: JsonResponse): Ok {
|
||||
if (res.err != null) {
|
||||
return constructError(res.err!.kind, res.err!.message);
|
||||
throw new (getErrorClass(res.err.kind))(res.err.message);
|
||||
}
|
||||
util.assert(res.ok != null);
|
||||
return res.ok;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue