Skip to content

Commit 53d58db

Browse files
committed
Hide stack traces for ErrnoError
1 parent 660c31f commit 53d58db

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/internal/error.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ export interface ErrnoErrorJSON extends ErrnoExceptionJSON {
1111
* An error with additional information about what happened
1212
* @category Internals
1313
*/
14-
export class ErrnoError extends ErrnoException implements NodeJS.ErrnoException {
15-
public static fromJSON(json: ErrnoErrorJSON): ErrnoError {
14+
export class ErrnoError extends ErrnoException {
15+
public static fromJSON(this: void, json: ErrnoErrorJSON): ErrnoError {
1616
const err = new ErrnoError(json.errno, json.message, json.path, json.syscall);
1717
err.code = json.code;
1818
err.stack = json.stack;
19+
Error.captureStackTrace?.(err, ErrnoError.fromJSON);
1920
return err;
2021
}
2122

22-
public static With(code: keyof typeof Errno, path?: string, syscall?: string): ErrnoError {
23-
return new ErrnoError(Errno[code], undefined, path, syscall);
23+
public static With(this: void, code: keyof typeof Errno, path?: string, syscall?: string): ErrnoError {
24+
const err = new ErrnoError(Errno[code], undefined, path, syscall);
25+
Error.captureStackTrace?.(err, ErrnoError.With);
26+
return err;
2427
}
2528

2629
public constructor(
@@ -30,6 +33,7 @@ export class ErrnoError extends ErrnoException implements NodeJS.ErrnoException
3033
syscall?: string
3134
) {
3235
super(errno, message, syscall);
36+
Error.captureStackTrace?.(this, this.constructor);
3337
}
3438

3539
public toString(): string {

0 commit comments

Comments
 (0)