using System;
using System.Diagnostics.CodeAnalysis;
namespace ComputeSharp.D2D1.Helpers;
///
/// Helper methods to efficiently throw exceptions.
///
internal static class ThrowHelper
{
///
/// Throws a new .
///
/// The argument name.
/// The message to include in the exception.
/// Thrown with the specified parameters.
[DoesNotReturn]
public static void ThrowArgumentException(string? name, string? message)
{
throw new ArgumentException(message, name);
}
///
/// Throws a new .
///
/// The type of expected result.
/// The argument name.
/// The message to include in the exception.
/// Thrown with the specified parameters.
/// This method always throws, so it actually never returns a value.
[DoesNotReturn]
public static T ThrowArgumentException(string? name, string? message)
{
throw new ArgumentException(message, name);
}
///
/// Throws a new .
///
/// The argument name.
/// The message to include in the exception.
/// Thrown with the specified parameters.
[DoesNotReturn]
public static void ThrowArgumentNullException(string? name, string? message)
{
throw new ArgumentNullException(name, message);
}
///
/// Throws a new .
///
/// The argument name.
/// Thrown with the specified parameter.
[DoesNotReturn]
public static void ThrowArgumentOutOfRangeException(string? name)
{
throw new ArgumentOutOfRangeException(name);
}
///
/// Throws a new .
///
/// The argument name.
/// The message to include in the exception.
/// Thrown with the specified parameter.
[DoesNotReturn]
public static void ThrowArgumentOutOfRangeException(string? name, string? message)
{
throw new ArgumentOutOfRangeException(name, message);
}
///
/// Throws a new .
///
/// The message to include in the exception.
/// Thrown with the specified parameter.
[DoesNotReturn]
public static void ThrowInvalidOperationException(string? message)
{
throw new InvalidOperationException(message);
}
///
/// Throws a new .
///
/// The message to include in the exception.
/// Thrown with the specified parameter.
[DoesNotReturn]
public static void ThrowNotSupportedException(string? message)
{
throw new NotSupportedException(message);
}
}