Skip to content

Commit 507308b

Browse files
authored
Merge pull request plotly#4750 from plotly/log-error-before-throw
Print error before calling throw
2 parents 561322e + 784ed7a commit 507308b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tasks/util/common.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ var fs = require('fs');
22
var exec = require('child_process').exec;
33
var falafel = require('falafel');
44

5+
function _throw(err) {
6+
console.log(err);
7+
throw err;
8+
}
9+
510
exports.execCmd = function(cmd, cb, errorCb) {
611
cb = cb ? cb : function() {};
7-
errorCb = errorCb ? errorCb : function(err) { if(err) throw err; };
12+
errorCb = errorCb ? errorCb : function(err) { if(err) _throw(err); };
813

914
exec(cmd, function(err) {
1015
errorCb(err);
@@ -15,7 +20,7 @@ exports.execCmd = function(cmd, cb, errorCb) {
1520

1621
exports.writeFile = function(filePath, content, cb) {
1722
fs.writeFile(filePath, content, function(err) {
18-
if(err) throw err;
23+
if(err) _throw(err);
1924
if(cb) cb();
2025
});
2126
};
@@ -63,7 +68,7 @@ exports.touch = function(filePath) {
6368
};
6469

6570
exports.throwOnError = function(err) {
66-
if(err) throw err;
71+
if(err) _throw(err);
6772
};
6873

6974
exports.findModuleList = function(pathToIndex) {

0 commit comments

Comments
 (0)