public static void ThrowIfFailed(this HResult result, string path = null) { if (result.Failed()) { throw result.GetException(path); } }
public void GetExceptionWithErrorInfo(HResult.Code hrCode) { HResult hr = hrCode; Exception expected = Marshal.GetExceptionForHR(hr); Exception actual = hr.GetException(IntPtr.Zero); // Consider actually initializing this. if (expected == null) { Assert.Null(actual); } else { Assert.IsType(expected.GetType(), actual); Assert.Equal(expected.Message, actual.Message); } }
public void GetException(HResult.Code hrCode) { HResult hr = hrCode; Exception expected = Marshal.GetExceptionForHR(hr); Exception actual = hr.GetException(); if (expected == null) { Assert.Null(actual); } else { Assert.IsType(expected.GetType(), actual); Assert.Equal(expected.Message, actual.Message); } }
public static void Throw(this HResult result, string?path = null) => throw result.GetException(path);
public static void Throw(this HResult result) => throw result.GetException();
public static void Throw(this HResult result, string?detail = null) => throw result.GetException(detail);