Skip to content

Commit 1a22f4c

Browse files
sbc100VirtualTim
authored andcommitted
Reduce the default verbosity of JS library error messages (emscripten-core#8339)
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.
1 parent d3fd009 commit 1a22f4c

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/modules.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,24 @@ var LibraryManager = {
160160
processed = processMacros(preprocess(src, filename));
161161
eval(processed);
162162
} catch(e) {
163-
var details = [e, e.lineNumber ? 'line number: ' + e.lineNumber : '', (e.stack || "").toString().replace('Object.<anonymous>', filename)];
163+
var details = [e, e.lineNumber ? 'line number: ' + e.lineNumber : ''];
164+
if (VERBOSE) {
165+
details.push((e.stack || "").toString().replace('Object.<anonymous>', filename));
166+
}
164167
if (processed) {
165-
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');
168+
error('failure to execute js library "' + filename + '": ' + details);
169+
if (VERBOSE) {
170+
error('preprocessed source (you can run a js engine on this to get a clearer error message sometimes):\n=============\n' + processed + '\n=============');
171+
} else {
172+
error('use -s VERBOSE to see more details')
173+
}
166174
} else {
167-
error('failure to process js library "' + filename + '": ' + details + '\noriginal source:\n=============\n' + src + '\n=============\n');
175+
error('failure to process js library "' + filename + '": ' + details);
176+
if (VERBOSE) {
177+
error('original source:\n=============\n' + src + '\n=============');
178+
} else {
179+
error('use -s VERBOSE to see more details')
180+
}
168181
}
169182
throw e;
170183
}

0 commit comments

Comments
 (0)