mirror of https://github.com/dahall/Vanara.git
Fixed bug in Win32Error.ThrowLastErrorIf method that would exception if error was success.
parent
3876cce9a0
commit
093916caae
|
@ -104,8 +104,12 @@ namespace Vanara.PInvoke
|
||||||
/// <param name="valueIsFailure">The delegate which returns <see langword="true"/> on failure.</param>
|
/// <param name="valueIsFailure">The delegate which returns <see langword="true"/> on failure.</param>
|
||||||
/// <param name="message">The message.</param>
|
/// <param name="message">The message.</param>
|
||||||
/// <returns>The <paramref name="value"/> passed in on success.</returns>
|
/// <returns>The <paramref name="value"/> passed in on success.</returns>
|
||||||
public static T ThrowLastErrorIf<T>(T value, Func<T, bool> valueIsFailure, string message = null) =>
|
public static T ThrowLastErrorIf<T>(T value, Func<T, bool> valueIsFailure, string message = null)
|
||||||
!valueIsFailure(value) ? value : throw GetLastError().GetException(message);
|
{
|
||||||
|
if (valueIsFailure(value))
|
||||||
|
GetLastError().ThrowIfFailed(message);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Throws the last error if the function returns <see langword="false"/>.</summary>
|
/// <summary>Throws the last error if the function returns <see langword="false"/>.</summary>
|
||||||
/// <param name="value">The value to check.</param>
|
/// <param name="value">The value to check.</param>
|
||||||
|
|
Loading…
Reference in New Issue