Improve Metro's TransformError message for transform errors.

Reviewed By: davidaurelio

Differential Revision: D5470538

fbshipit-source-id: dea3e798c26964bb789917e73bb06a7629af7aa4
This commit is contained in:
Christoph Nakazawa 2017-07-25 13:52:33 -07:00 committed by Facebook Github Bot
parent ce0da03a05
commit 521e25bded
2 changed files with 6 additions and 7 deletions

View File

@ -204,7 +204,6 @@ function formatGenericError(err, filename) {
var msg = 'TransformError: ' + filename + ': ' + err.message; var msg = 'TransformError: ' + filename + ': ' + err.message;
var error = new TransformError(); var error = new TransformError();
var stack = (err.stack || '').split('\n').slice(0, -1); var stack = (err.stack || '').split('\n').slice(0, -1);
stack.push(msg);
error.stack = stack.join('\n'); error.stack = stack.join('\n');
error.message = msg; error.message = msg;
error.type = 'TransformError'; error.type = 'TransformError';

View File

@ -269,21 +269,21 @@ class TerminalReporter {
return; return;
} }
let message = (error.snippet == null && error.stack != null)
? error.stack
//$FlowFixMe T19379628 //$FlowFixMe T19379628
let message = error.message; : error.message;
//$FlowFixMe T19379628 //$FlowFixMe T19379628
if (error.filename && !message.includes(error.filename)) { if (error.filename && !message.includes(error.filename)) {
//$FlowFixMe T19379628 //$FlowFixMe T19379628
message += ` [${error.filename}]`; message += ` [${error.filename}]`;
} }
let str = JSON.stringify(message);
if (error.snippet != null) { if (error.snippet != null) {
//$FlowFixMe T19379628 //$FlowFixMe T19379628
str += '\n' + error.snippet; message += '\n' + error.snippet;
} }
this._logBundlingErrorMessage(message);
this._logBundlingErrorMessage(str);
} }
_logBundlingErrorMessage(message: string) { _logBundlingErrorMessage(message: string) {