From e457b4609ed7630ac8920cea90c9e1282b4914ca Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Wed, 31 Jul 2024 23:57:21 +0500 Subject: [PATCH] Don't log stack traces for cancelled operations (#327) This PR fixes an issue where the `LogResultStackTrace` method would log stack traces for results that encountered an error due to a cancelled operation/task. The `LoggerExtensions` class already skipped `TaskCanceledException`s, but didn't skip `OperationCanceledException`s (which is a parent of `TaskCanceledException`). The patch specifically does not affect *inner* results which are canceled. Skipping logging these could hide the true cause of an error which appears important --- TeamOctolings.Octobot/Extensions/LoggerExtensions.cs | 2 +- TeamOctolings.Octobot/Extensions/ResultExtensions.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TeamOctolings.Octobot/Extensions/LoggerExtensions.cs b/TeamOctolings.Octobot/Extensions/LoggerExtensions.cs index 76fa386..fac4dda 100644 --- a/TeamOctolings.Octobot/Extensions/LoggerExtensions.cs +++ b/TeamOctolings.Octobot/Extensions/LoggerExtensions.cs @@ -25,7 +25,7 @@ public static class LoggerExtensions if (result.Error is ExceptionError exe) { - if (exe.Exception is TaskCanceledException) + if (exe.Exception is OperationCanceledException) { return; } diff --git a/TeamOctolings.Octobot/Extensions/ResultExtensions.cs b/TeamOctolings.Octobot/Extensions/ResultExtensions.cs index d7ef7d7..6872d34 100644 --- a/TeamOctolings.Octobot/Extensions/ResultExtensions.cs +++ b/TeamOctolings.Octobot/Extensions/ResultExtensions.cs @@ -23,7 +23,7 @@ public static class ResultExtensions private static void LogResultStackTrace(Result result) { - if (result.IsSuccess) + if (result.IsSuccess || result.Error is ExceptionError { Exception: OperationCanceledException }) { return; }