I am working on a project in my company which relies on log information a lot. I can’t reveal name and working of the system here because it’s company property but it is very complicated and high performance system which log everything it do. In the log there was some error’s coming called “ENOENT” from LSTAT call. My challenge was to dig into it and make this error more descriptive so that the administrator of the System understand the error’s from log.
So i surfed some forums and found nothing much informative, then i look over the man page of LSTAT and there was my answer, every possible error LSTAT can throw is been listed there. My job was then to write few lines of code and that’s it. But while surfing over this issue i figured many people are facing this issue in different way and i thought to make it useful for them too, so i wrote some lines of code and made this Sweet LSTAT node module which is available at npmjs.org
You can install it using npm command as follows.
You may require SUDO access in Linux or Mac system.
How to use it:
It have two facility:
- Show error from error number ( 1,2..)
- Show error from Code (ENOENT,FD..)
You can use both of it at a time. Let me explain you with this sample code.
//FYI: err is object contains errno, code of error.
//Do other task
In this way if error occurs we can come to know the details about it and also by googling the detail, we can easily determine the cause of an error. I hope this helps many people out there who work on node and find some difficulty in debugging node.