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());
+ }
+ }
}