Display snippets of TransformErrors

Reviewed By: cpojer

Differential Revision: D5247080

fbshipit-source-id: a0c4515476246e6da4c33c9129f6273af838d04f
This commit is contained in:
David Aurelio 2017-06-16 09:27:09 -07:00 committed by Facebook Github Bot
parent af67937bba
commit 2a085f0c1b
1 changed files with 16 additions and 2 deletions

View File

@ -18,6 +18,7 @@ const reporting = require('./reporting');
const throttle = require('lodash/throttle');
const util = require('util');
import type Transformer from '../JSTransformer';
import type {BundleOptions} from '../Server';
import type Terminal from './Terminal';
import type {ReportableEvent, GlobalCacheDisabledReason} from './reporting';
@ -248,8 +249,21 @@ class TerminalReporter {
* these are operational errors, not programming errors, and the stacktrace
* is not actionable to end users.
*/
_logBundlingError(error: Error) {
const str = JSON.stringify(error.message);
_logBundlingError(error: Error | Transformer.TransformError) {
//$FlowFixMe T19379628
let message = error.message;
//$FlowFixMe T19379628
if (error.filename && !message.includes(error.filename)) {
//$FlowFixMe T19379628
message += ` [${error.filename}]`;
}
let str = JSON.stringify(message);
if (error.snippet != null) {
//$FlowFixMe T19379628
str += '\n' + error.snippet;
}
reporting.logError(this.terminal, 'bundling failed: %s', str);
}