From 784ed7a1d21af75d7f0ce11f4007081f02e37447 Mon Sep 17 00:00:00 2001 From: archmoj Date: Thu, 9 Apr 2020 14:44:37 -0400 Subject: [PATCH] log error before calling throw --- tasks/util/common.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tasks/util/common.js b/tasks/util/common.js index e2fa0ed53a2..0987dfc2536 100644 --- a/tasks/util/common.js +++ b/tasks/util/common.js @@ -2,9 +2,14 @@ var fs = require('fs'); var exec = require('child_process').exec; var falafel = require('falafel'); +function _throw(err) { + console.log(err); + throw err; +} + exports.execCmd = function(cmd, cb, errorCb) { cb = cb ? cb : function() {}; - errorCb = errorCb ? errorCb : function(err) { if(err) throw err; }; + errorCb = errorCb ? errorCb : function(err) { if(err) _throw(err); }; exec(cmd, function(err) { errorCb(err); @@ -15,7 +20,7 @@ exports.execCmd = function(cmd, cb, errorCb) { exports.writeFile = function(filePath, content, cb) { fs.writeFile(filePath, content, function(err) { - if(err) throw err; + if(err) _throw(err); if(cb) cb(); }); }; @@ -63,7 +68,7 @@ exports.touch = function(filePath) { }; exports.throwOnError = function(err) { - if(err) throw err; + if(err) _throw(err); }; exports.findModuleList = function(pathToIndex) {