OpenTelemetry.Internal.Guard
Methods for guarding against exception throwing values.
public static void ThrowIfDefault<T>(T value, string paramName = null) where T : struct, IEquatable<T>
Throw an exception if the value equals default.
Throw an exception if the value is not considered a valid timeout.
public static void ThrowIfNegative(int value, string message = "Must not be negative", string paramName = null)
Throw an exception if the value is negative.
Throw an exception if the value is not of the expected type.
Throw an exception if the value is null.
Throw an exception if the value is null or empty.
Throw an exception if the value is null or whitespace.
public static void ThrowIfOutOfRange(int value, string paramName = null, int min = -2147483648, int max = 2147483647, string minName = null, string maxName = null, string message = null)
Throw an exception if the value is not within the given range.
public static void ThrowIfOutOfRange(double value, string paramName = null, double min = -1.7976931348623157E+308, double max = 1.7976931348623157E+308, string minName = null, string maxName = null, string message = null)
Throw an exception if the value is not within the given range.
public static void ThrowIfUndefined<TEnum>(TEnum value, string paramName = null) where TEnum : struct, Enum
Throw an exception if the enum value is not a defined member of
TEnum.
public static void ThrowIfUndefinedOrDefault<TEnum>(TEnum value, string paramName = null) where TEnum : struct, Enum
Throw an exception if the enum value is the default (zero) value or is not a
defined member of TEnum.
public static void ThrowIfZero(int value, string message = "Must not be zero", string paramName = null)
Throw an exception if the value is zero.