🐴 said: Ever find yourself needing more details about Node.js errors? Me too, so node-errno contains the errno mappings direct from libuv so you can use them in your code.
varerrno=require('errno')functionerrmsg(err){varstr='Error: '// if it's a libuv error then get the description from errnoif(errno.errno[err.errno])str+=errno.errno[err.errno].descriptionelsestr+=err.message// if it's a `fs` error then it'll have a 'path' propertyif(err.path)str+=' ['+err.path+']'returnstr}varfs=require('fs')fs.readFile('thisisnotarealfile.txt',function(err,data){if(err)console.log(errmsg(err))})
Use as a command line tool:
1234567891011121314
~$errno53{"errno":53,"code":"ENOTEMPTY","description":"directory not empty"}~$errnoEROFS{"errno":56,"code":"EROFS","description":"read-only file system"}~$errnofooNosucherrno/code:"foo"