Skip to content

Commit

Permalink
Reduce the default verbosity of JS library error messages (#8339)
Browse files Browse the repository at this point in the history
Currently the entire library is printed which makes seeing the
actual error very difficult.  Normally the filename and line number
should be sufficient and we can put the rest of it befind VERBOSE=1.
  • Loading branch information
sbc100 authored Mar 26, 2019
1 parent 41a3f7a commit 4840157
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,24 @@ var LibraryManager = {
processed = processMacros(preprocess(src, filename));
eval(processed);
} catch(e) {
var details = [e, e.lineNumber ? 'line number: ' + e.lineNumber : '', (e.stack || "").toString().replace('Object.<anonymous>', filename)];
var details = [e, e.lineNumber ? 'line number: ' + e.lineNumber : ''];
if (VERBOSE) {
details.push((e.stack || "").toString().replace('Object.<anonymous>', filename));
}
if (processed) {
error('failure to execute js library "' + filename + '": ' + details + '\npreprocessed source (you can run a js engine on this to get a clearer error message sometimes):\n=============\n' + processed + '\n=============\n');
error('failure to execute js library "' + filename + '": ' + details);
if (VERBOSE) {
error('preprocessed source (you can run a js engine on this to get a clearer error message sometimes):\n=============\n' + processed + '\n=============');
} else {
error('use -s VERBOSE to see more details')
}
} else {
error('failure to process js library "' + filename + '": ' + details + '\noriginal source:\n=============\n' + src + '\n=============\n');
error('failure to process js library "' + filename + '": ' + details);
if (VERBOSE) {
error('original source:\n=============\n' + src + '\n=============');
} else {
error('use -s VERBOSE to see more details')
}
}
throw e;
}
Expand Down

0 comments on commit 4840157

Please sign in to comment.