diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-01-24 07:03:11 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-02-01 15:52:18 +0800 |
commit | 167e22937c612e18678e45e73a89dcc27e72fdc5 (patch) | |
tree | 44544a4b2f4371231c5721cd4977244e9c6fb8de /lib | |
parent | 32bf0f6c5b3648a487c3fc56d0830de2ceeb60a5 (diff) | |
download | android-node-v8-167e22937c612e18678e45e73a89dcc27e72fdc5.tar.gz android-node-v8-167e22937c612e18678e45e73a89dcc27e72fdc5.tar.bz2 android-node-v8-167e22937c612e18678e45e73a89dcc27e72fdc5.zip |
fs: throw errors from fs.linkSync in JS
PR-URL: https://github.com/nodejs/node/pull/18348
Refs: https://github.com/nodejs/node/issues/18106
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fs.js | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -1280,8 +1280,15 @@ fs.linkSync = function(existingPath, newPath) { nullCheck(newPath); validatePath(existingPath, 'existingPath'); validatePath(newPath, 'newPath'); - return binding.link(pathModule.toNamespacedPath(existingPath), - pathModule.toNamespacedPath(newPath)); + + const ctx = { path: existingPath, dest: newPath }; + const result = binding.link(pathModule.toNamespacedPath(existingPath), + pathModule.toNamespacedPath(newPath), + undefined, ctx); + if (ctx.errno !== undefined) { + throw new errors.uvException(ctx); + } + return result; }; fs.unlink = function(path, callback) { |