1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-20 00:43:36 +03:00

change: log result stacktrace instead of asserting

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-12-31 14:09:17 +05:00
parent aa860b2fc4
commit 5f007ada74
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF

View file

@ -58,7 +58,7 @@ public sealed class Profiler
/// <returns>The original result.</returns> /// <returns>The original result.</returns>
public Result PopWithResult(Result result) public Result PopWithResult(Result result)
{ {
Debug.Assert(result.IsSuccess); LogResultStackTrace(result);
Pop(); Pop();
return result; return result;
} }
@ -116,7 +116,7 @@ public sealed class Profiler
/// <returns>The original result.</returns> /// <returns>The original result.</returns>
public Result ReportWithResult(Result result) public Result ReportWithResult(Result result)
{ {
Debug.Assert(result.IsSuccess); LogResultStackTrace(result);
PopAndReport(); PopAndReport();
return result; return result;
} }
@ -129,4 +129,14 @@ public sealed class Profiler
{ {
return ReportWithResult(Result.FromSuccess()); 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());
}
}
} }