Skip to content

Commit

Permalink
Metro: Omit SyntaxError Stack Traces
Browse files Browse the repository at this point in the history
Reviewed By: zackargyle

Differential Revision: D15453889

fbshipit-source-id: 09e07f343075f66dee2cfdbe55af0644a61566f3
  • Loading branch information
yungsters authored and facebook-github-bot committed May 23, 2019
1 parent 5f899d9 commit 39892a2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/metro/src/lib/TerminalReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,16 @@ class TerminalReporter {
return;
}

let message =
error.snippet == null && error.stack != null
? error.stack
: error.message;
let {message} = error;

// Do not log the stack trace for SyntaxError (because it will always be in
// the parser, which is not helpful).
if (!(error instanceof SyntaxError)) {
if (error.snippet == null && error.stack != null) {
message = error.stack;
}
}

if (error.filename && !message.includes(error.filename)) {
message += ` [${error.filename}]`;
}
Expand Down

0 comments on commit 39892a2

Please sign in to comment.