mirror of
https://github.com/status-im/metro.git
synced 2025-02-18 14:07:15 +00:00
Display snippets of TransformErrors
Reviewed By: cpojer Differential Revision: D5247080 fbshipit-source-id: a0c4515476246e6da4c33c9129f6273af838d04f
This commit is contained in:
parent
af67937bba
commit
2a085f0c1b
@ -18,6 +18,7 @@ const reporting = require('./reporting');
|
|||||||
const throttle = require('lodash/throttle');
|
const throttle = require('lodash/throttle');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
|
||||||
|
import type Transformer from '../JSTransformer';
|
||||||
import type {BundleOptions} from '../Server';
|
import type {BundleOptions} from '../Server';
|
||||||
import type Terminal from './Terminal';
|
import type Terminal from './Terminal';
|
||||||
import type {ReportableEvent, GlobalCacheDisabledReason} from './reporting';
|
import type {ReportableEvent, GlobalCacheDisabledReason} from './reporting';
|
||||||
@ -248,8 +249,21 @@ class TerminalReporter {
|
|||||||
* these are operational errors, not programming errors, and the stacktrace
|
* these are operational errors, not programming errors, and the stacktrace
|
||||||
* is not actionable to end users.
|
* is not actionable to end users.
|
||||||
*/
|
*/
|
||||||
_logBundlingError(error: Error) {
|
_logBundlingError(error: Error | Transformer.TransformError) {
|
||||||
const str = JSON.stringify(error.message);
|
//$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);
|
reporting.logError(this.terminal, 'bundling failed: %s', str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user