Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Commit

Permalink
Log parse exceptions instead of just throwing them away (#1777)
Browse files Browse the repository at this point in the history
(cherry picked from commit 1c9f8fe)
  • Loading branch information
jakebailey authored and Mikhail Arkhipov committed Jun 15, 2020
1 parent 9358e41 commit 79c7f92
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Analysis/Ast/Impl/Modules/PythonModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,16 @@ private void Parse() {
_linkedParseCts = CancellationTokenSource.CreateLinkedTokenSource(_disposeToken.CancellationToken, _parseCts.Token);

ContentState = State.Parsing;
_parsingTask = Task.Run(() => Parse(_linkedParseCts.Token), _linkedParseCts.Token);
_parsingTask = Task.Run(() => ParseAndLogExceptions(_linkedParseCts.Token), _linkedParseCts.Token);
}

private void ParseAndLogExceptions(CancellationToken cancellationToken) {
try {
Parse(cancellationToken);
} catch (Exception ex) when (!(ex is OperationCanceledException)) {
Log?.Log(TraceEventType.Warning, $"Exception while parsing {FilePath}: {ex}");
throw;
}
}

private void Parse(CancellationToken cancellationToken) {
Expand Down

0 comments on commit 79c7f92

Please sign in to comment.