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) {