From 9fbc5cff185b2db2ed0a3fdf61e20c3c193b24f2 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 8 Nov 2019 13:39:20 -0800 Subject: [PATCH] Log parse exceptions instead of just throwing them away --- 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 263d4af31..d1463ef62 100644 --- a/src/Analysis/Ast/Impl/Modules/PythonModule.cs +++ b/src/Analysis/Ast/Impl/Modules/PythonModule.cs @@ -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 { + Parse(cancellationToken); + } catch (Exception ex) when (!(ex is OperationCanceledException)) { + Log?.Log(TraceEventType.Warning, $"Exception while parsing {FilePath}: {ex}"); + throw; + } } private void Parse(CancellationToken cancellationToken) {