1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 08:41:13 +03:00

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
This commit is contained in:
Octol1ttle 2024-07-31 23:57:21 +05:00 committed by GitHub
parent d6d2660fb0
commit e457b4609e
Signed by: GitHub
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -25,7 +25,7 @@ public static class LoggerExtensions
if (result.Error is ExceptionError exe) if (result.Error is ExceptionError exe)
{ {
if (exe.Exception is TaskCanceledException) if (exe.Exception is OperationCanceledException)
{ {
return; return;
} }

View file

@ -23,7 +23,7 @@ public static class ResultExtensions
private static void LogResultStackTrace(Result result) private static void LogResultStackTrace(Result result)
{ {
if (result.IsSuccess) if (result.IsSuccess || result.Error is ExceptionError { Exception: OperationCanceledException })
{ {
return; return;
} }