summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-01-24 09:20:30 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-02-01 15:52:36 +0800
commitb3a7df7c6dddcc4aaf2106d569a2a4c017e9699c (patch)
tree24b3501b3f0c78e81272e0191362d3d8d3cc2ed9 /lib
parent5583981c5296be0383c934caf0c0ddd5e6bda379 (diff)
downloadandroid-node-v8-b3a7df7c6dddcc4aaf2106d569a2a4c017e9699c.tar.gz
android-node-v8-b3a7df7c6dddcc4aaf2106d569a2a4c017e9699c.tar.bz2
android-node-v8-b3a7df7c6dddcc4aaf2106d569a2a4c017e9699c.zip
fs: throw errors from fs.ftruncateSync 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.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/fs.js b/lib/fs.js
index 7087644674..8eaba7984c 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -995,7 +995,11 @@ fs.ftruncateSync = function(fd, len = 0) {
validateUint32(fd, 'fd');
validateLen(len);
len = Math.max(0, len);
- return binding.ftruncate(fd, len);
+ const ctx = {};
+ binding.ftruncate(fd, len, undefined, ctx);
+ if (ctx.errno !== undefined) {
+ throw new errors.uvException(ctx);
+ }
};
fs.rmdir = function(path, callback) {