@@ -11,16 +11,19 @@ export interface ErrnoErrorJSON extends ErrnoExceptionJSON {
11
11
* An error with additional information about what happened
12
12
* @category Internals
13
13
*/
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 {
16
16
const err = new ErrnoError ( json . errno , json . message , json . path , json . syscall ) ;
17
17
err . code = json . code ;
18
18
err . stack = json . stack ;
19
+ Error . captureStackTrace ?.( err , ErrnoError . fromJSON ) ;
19
20
return err ;
20
21
}
21
22
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 ;
24
27
}
25
28
26
29
public constructor (
@@ -30,6 +33,7 @@ export class ErrnoError extends ErrnoException implements NodeJS.ErrnoException
30
33
syscall ?: string
31
34
) {
32
35
super ( errno , message , syscall ) ;
36
+ Error . captureStackTrace ?.( this , this . constructor ) ;
33
37
}
34
38
35
39
public toString ( ) : string {
0 commit comments