summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/errors.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/internal/errors.ts')
-rw-r--r--ext/node/polyfills/internal/errors.ts30
1 files changed, 26 insertions, 4 deletions
diff --git a/ext/node/polyfills/internal/errors.ts b/ext/node/polyfills/internal/errors.ts
index 6529e9894..9ec9f9949 100644
--- a/ext/node/polyfills/internal/errors.ts
+++ b/ext/node/polyfills/internal/errors.ts
@@ -18,7 +18,7 @@
*/
import { primordials } from "ext:core/mod.js";
-const { JSONStringify } = primordials;
+const { JSONStringify, SymbolFor } = primordials;
import { format, inspect } from "ext:deno_node/internal/util/inspect.mjs";
import { codes } from "ext:deno_node/internal/error_codes.ts";
import {
@@ -421,8 +421,11 @@ export interface NodeSystemErrorCtx {
// `err.info`.
// The context passed into this error must have .code, .syscall and .message,
// and may have .path and .dest.
-class NodeSystemError extends NodeErrorAbstraction {
+class NodeSystemError extends Error {
+ code: string;
constructor(key: string, context: NodeSystemErrorCtx, msgPrefix: string) {
+ super();
+ this.code = key;
let message = `${msgPrefix}: ${context.syscall} returned ` +
`${context.code} (${context.message})`;
@@ -433,8 +436,6 @@ class NodeSystemError extends NodeErrorAbstraction {
message += ` => ${context.dest}`;
}
- super("SystemError", key, message);
-
captureLargerStackTrace(this);
Object.defineProperties(this, {
@@ -444,6 +445,18 @@ class NodeSystemError extends NodeErrorAbstraction {
writable: false,
configurable: true,
},
+ name: {
+ value: "SystemError",
+ enumerable: false,
+ writable: true,
+ configurable: true,
+ },
+ message: {
+ value: message,
+ enumerable: false,
+ writable: true,
+ configurable: true,
+ },
info: {
value: context,
enumerable: true,
@@ -502,6 +515,15 @@ class NodeSystemError extends NodeErrorAbstraction {
override toString() {
return `${this.name} [${this.code}]: ${this.message}`;
}
+
+ // deno-lint-ignore no-explicit-any
+ [SymbolFor("nodejs.util.inspect.custom")](_recurseTimes: number, ctx: any) {
+ return inspect(this, {
+ ...ctx,
+ getters: true,
+ customInspect: false,
+ });
+ }
}
function makeSystemErrorWithCode(key: string, msgPrfix: string) {