From ef0abe6649148933d31f6196fe21caddd2bae6ca Mon Sep 17 00:00:00 2001 From: olya Date: Wed, 11 Apr 2018 12:34:01 +0300 Subject: [PATCH] add try-catch around fs.writeSync --- util/utils.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/util/utils.js b/util/utils.js index 4091292..d3ef5b3 100644 --- a/util/utils.js +++ b/util/utils.js @@ -112,8 +112,15 @@ module.exports = (function() { fd = fs.openSync(path, 'w', 438); } if (fd) { - fs.writeSync(fd, content, 0, content.length, 0); - fs.closeSync(fd); + try { + fs.writeSync(fd, content, 0, content.length, 0); + } + catch (e){ + throw e; + } + finally { + fs.closeSync(fd); + } } fs.chmodSync(path, attr || 438); return true;