diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-02-16 13:25:21 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-02-27 20:34:18 +0800 |
commit | 4eb45b884d9bd1f13979047750ad680275f4a348 (patch) | |
tree | 0bffb5e15f59ab58888f28e4e75dc663bf85bce2 /lib | |
parent | d2dc2a50113492840e77e4f5d3df6ff75fa986a4 (diff) | |
download | android-node-v8-4eb45b884d9bd1f13979047750ad680275f4a348.tar.gz android-node-v8-4eb45b884d9bd1f13979047750ad680275f4a348.tar.bz2 android-node-v8-4eb45b884d9bd1f13979047750ad680275f4a348.zip |
fs: throw copyFileSync errors in JS
PR-URL: https://github.com/nodejs/node/pull/18871
Refs: https://github.com/nodejs/node/issues/18106
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fs.js | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -1859,7 +1859,7 @@ fs.copyFile = function(src, dest, flags, callback) { callback = flags; flags = 0; } else if (typeof callback !== 'function') { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'callback', 'Function'); + throw new errors.TypeError('ERR_INVALID_CALLBACK'); } src = getPathFromURL(src); @@ -1882,10 +1882,13 @@ fs.copyFileSync = function(src, dest, flags) { validatePath(src, 'src'); validatePath(dest, 'dest'); + const ctx = { path: src, dest }; // non-prefixed + src = pathModule._makeLong(src); dest = pathModule._makeLong(dest); flags = flags | 0; - binding.copyFile(src, dest, flags); + binding.copyFile(src, dest, flags, undefined, ctx); + handleErrorFromBinding(ctx); }; |