<PackageReference Include="NUnit" Version="5.1.0-beta.1" />

NUnit.Framework.ExceptionExtensions

static class ExceptionExtensions
public static Result<IDictionary> GetDataWithoutThrowing(this Exception exception)

If Data throws, returns "SomeException was thrown by the Exception.Data property."

public static string GetMessageWithoutThrowing(this Exception exception)

If Message throws, returns "SomeException was thrown by the Exception.Message property."

public static string GetStackTraceWithoutThrowing(this Exception exception, StackFilter filter)

Returns StackTrace filtered by filter, or unfiltered if filter is null. If StackTrace throws, returns "SomeException was thrown by the Exception.StackTrace property." unfiltered. See also GetCallerStackTraceWithoutThrowing.

Sets the result state and message of the current test before the exception is thrown, so code that catches the exception can read them from Result.