From 5f007ada7467fecc5dd693736aa49168d1353a02 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Sun, 31 Dec 2023 14:09:17 +0500 Subject: [PATCH] change: log result stacktrace instead of asserting Signed-off-by: Octol1ttle --- src/Services/Profiler/Profiler.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Services/Profiler/Profiler.cs b/src/Services/Profiler/Profiler.cs index 0047493..7bbd1e0 100644 --- a/src/Services/Profiler/Profiler.cs +++ b/src/Services/Profiler/Profiler.cs @@ -58,7 +58,7 @@ public sealed class Profiler /// The original result. public Result PopWithResult(Result result) { - Debug.Assert(result.IsSuccess); + LogResultStackTrace(result); Pop(); return result; } @@ -116,7 +116,7 @@ public sealed class Profiler /// The original result. public Result ReportWithResult(Result result) { - Debug.Assert(result.IsSuccess); + LogResultStackTrace(result); PopAndReport(); return result; } @@ -129,4 +129,14 @@ public sealed class Profiler { return ReportWithResult(Result.FromSuccess()); } + + [Conditional("DEBUG")] + private void LogResultStackTrace(Result result) + { + if (!result.IsSuccess) + { + _logger.LogError("Profiled result was not successful: {ResultMessage}{NewLine}{StackTrace}", + result.Error.Message, Environment.NewLine, new StackTrace(2, true).ToString()); + } + } }