Adds fallback for ExceptionFormatter in AOT

This commit is contained in:
Phil Scott 2024-11-20 10:37:30 -05:00 committed by Patrik Svensson
parent 2a8810affd
commit 2be8e8da4e

View File

@ -27,6 +27,13 @@ internal static class ExceptionFormatter
throw new ArgumentNullException(nameof(exception));
}
// fallback to default ToString() if someone in an AOT is insisting on using this method
var stackTrace = new StackTrace(exception, fNeedFileInfo: false);
if (stackTrace.GetFrame(0)?.GetMethod() is null)
{
return new Text(exception.ToString());
}
return new Rows(GetMessage(exception, settings), GetStackFrames(exception, settings)).Expand();
}