diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-16 23:28:38 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-20 12:04:35 +0200 |
commit | 0161ec87af3d71b10d8ce679c8a1a64358fae8dc (patch) | |
tree | fda63e078b5729cdb8c17329a90dad8306b003d9 /lib/util.js | |
parent | d4c14c1fe5402b8c3b1d582070ccbf3ae40f5b1f (diff) | |
download | node-new-0161ec87af3d71b10d8ce679c8a1a64358fae8dc.tar.gz |
src, lib: deduplicate errnoException
Diffstat (limited to 'lib/util.js')
-rw-r--r-- | lib/util.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/util.js b/lib/util.js index 4f9d06943e..f02aa8f6a4 100644 --- a/lib/util.js +++ b/lib/util.js @@ -601,3 +601,15 @@ exports.pump = exports.deprecate(function(readStream, writeStream, callback) { call(err); }); }, 'util.pump(): Use readableStream.pipe() instead'); + + +var uv; +exports._errnoException = function(err, syscall) { + if (typeof uv === 'undefined') uv = process.binding('uv'); + var errname = uv.errname(err); + var e = new Error(syscall + ' ' + errname); + e.code = errname; + e.errno = errname; + e.syscall = syscall; + return e; +}; |