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

Log parse exceptions instead of just throwing them away #1777

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -313,7 +313,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 {
jakebailey marked this conversation as resolved.
Show resolved Hide resolved
Parse(cancellationToken);
} catch (Exception ex) when (!(ex is OperationCanceledException)) {
jakebailey marked this conversation as resolved.
Show resolved Hide resolved
Log?.Log(TraceEventType.Warning, $"Exception while parsing {FilePath}: {ex}");
throw;
}
}

private void Parse(CancellationToken cancellationToken) {
Expand Down