I'm writing a simple application with Node that connects to a WebSocket server and retrieve's some information on a set interval. The application needs to be able to handle the possibility of different errors arising from the WebSocket. When I attach a listener to the error
event of the socket, the following is an example of the error object that the application receives:
{
errno: -4073,
code: 'EHOSTUNREACH',
syscall: 'connect',
address: '<Server's IP Address>',
port: <Port #>
}
This is fine. I understand what all of this means. The host is unreachable (which is true, the machine it was tested on has no network connection).
My issue comes with interpreting other errors. I would like to properly handle and report on each error code, like ECONNREFUSED
or ECONNRESET
and log them to console with some description that makes sense. I would like to find a list of these ECONN
errors so I can implement proper handling for the ones I know are most likely to occur.
I have Googled and Googled, looked at READMEs, searched for keywords with different packages, generic terms, specific terms, I even tried quoting that specific error code number -4073
and I can't find anything. I have done a global search of my node_modules
for some of these keywords and can't find anything. Can someone please point me to a list of where these specific error messages can be found?
Those errors are defined in the Standard C library, they aren't Node's stuff.
Start here: errno(3) — Linux manual page