Last active
March 3, 2025 22:59
-
-
Save reporter123/7c10e565fb849635787321766b7f8ad8 to your computer and use it in GitHub Desktop.
Compelete typescript definition for node's SystemError. A partial definition exists within TypeScript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Missing from TypeScript but documented by node. | |
See https://nodejs.org/api/errors.html#class-systemerror | |
*/ | |
interface NodeSystemError extends Error{ | |
address?: string; //If present, the address to which a network connection failed | |
code:string;// The string error code | |
dest:string;// If present, the file path destination when reporting a file system error | |
errno:number;// The system-provided error number | |
info?:Object;// If present, extra details about the error condition | |
message:string;// A system-provided human-readable description of the error | |
path?:string;// If present, the file path when reporting a file system error | |
port?:number;// If present, the network connection port that is not available | |
syscall:string;// The name of the system call that triggered the error | |
} | |
export type { NodeSystemError }; |
I believe I eventual found some of this in the existing typescript files but nothing like this where it was all in one place.
You may want to use NodeJS.ErrnoException
from @types/node
, which is somewhat similar
I wrote this before discovering the official type which is preferable since it will be kept updated should node change. The official type does not currently include all documented attributes. However it should work for most use cases.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Extremely useful. Thank you!