Things like EPERM, EONENT are the error names(codes) which represent different system call error. For example:
- EPERM: Operation not permitted.
- ENOENT: No such file or directory.
Of course, there are not only two of them. I searched Node.js’s API and find an exhausitive list which shows all those error codes and their meanings. What’s more, there is a link which refers to the <errno.h>
header file in Linux, which says:
All the error names specified by POSIX.1 must have distinct values, with the exception of EAGAIN and EWOULDBLOCK, which may be the same.
I found the corresponding POSIX.1 specification here, and this is the latest version of <errno.h>
. As it says, it’s an extension of ISO C standard, and Node.js is mainly based on C, so there is no wonder that Node.js will use those strange names.
Log Errors Easier
When we use those APIs in Node.js which handle the system call and error happens, those methods will return an error as the first parameter of the callback. It’s not easy for us to remember each error and corresponding description, so our error message would be hard to read. Fortunately, there is a library node-errno that can help us with that. You can pass the errno to it and it will return a description about it. So now we have more friendly error message~