fix(compiler-cli): Fix swallowed Error messages (#20846)

This commit fixes a bug in which non-formatted errors are silently
dropped.

Internal issue: b/67739418

PR Close #20846
This commit is contained in:
Keen Yee Liau
2017-12-06 15:27:23 -08:00
committed by Jason Aden
parent c2dbc55f11
commit 073f485c72
2 changed files with 46 additions and 13 deletions

View File

@ -869,17 +869,21 @@ function syntaxErrorToDiagnostics(error: Error): Diagnostic[] {
source: SOURCE,
code: DEFAULT_ERROR_CODE
}));
} else {
if (isFormattedError(error)) {
return [{
messageText: error.message,
chain: error.chain && diagnosticChainFromFormattedDiagnosticChain(error.chain),
category: ts.DiagnosticCategory.Error,
source: SOURCE,
code: DEFAULT_ERROR_CODE,
position: error.position
}];
}
} else if (isFormattedError(error)) {
return [{
messageText: error.message,
chain: error.chain && diagnosticChainFromFormattedDiagnosticChain(error.chain),
category: ts.DiagnosticCategory.Error,
source: SOURCE,
code: DEFAULT_ERROR_CODE,
position: error.position
}];
}
return [];
}
// Produce a Diagnostic anyway since we know for sure `error` is a SyntaxError
return [{
messageText: error.message,
category: ts.DiagnosticCategory.Error,
code: DEFAULT_ERROR_CODE,
source: SOURCE,
}];
}