From 79c7f927fc97b392b0829e25c2f17c29af0156c4 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 8 Nov 2019 14:30:18 -0800 Subject: [PATCH] Log parse exceptions instead of just throwing them away (#1777) (cherry picked from commit 1c9f8fe51c1e2fd5e0e562dfd20a324ca7c88cda) --- src/Analysis/Ast/Impl/Modules/PythonModule.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Analysis/Ast/Impl/Modules/PythonModule.cs b/src/Analysis/Ast/Impl/Modules/PythonModule.cs index ecd422062..9f92e1f94 100644 --- a/src/Analysis/Ast/Impl/Modules/PythonModule.cs +++ b/src/Analysis/Ast/Impl/Modules/PythonModule.cs @@ -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) {