From 694dc5cbbbb99a0c96a5600a11c0555dabbe45de Mon Sep 17 00:00:00 2001
From: MartyIX <203266+MartyIX@users.noreply.github.com>
Date: Thu, 27 Aug 2020 14:06:08 +0200
Subject: [PATCH] ExtensionMethods: Add `parameterName` when throwing
`ArgumentException`.
---
CryptoExchange.Net/ExtensionMethods.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/CryptoExchange.Net/ExtensionMethods.cs b/CryptoExchange.Net/ExtensionMethods.cs
index 1ac235b..3f1df21 100644
--- a/CryptoExchange.Net/ExtensionMethods.cs
+++ b/CryptoExchange.Net/ExtensionMethods.cs
@@ -172,7 +172,7 @@ namespace CryptoExchange.Net
tokenRegistration.Dispose();
}
}
-
+
///
/// Wait one async
///
@@ -225,7 +225,7 @@ namespace CryptoExchange.Net
{
if (!allowedValues.Contains(value))
throw new ArgumentException(
- $"{value} not allowed for parameter {argumentName}, allowed values: {string.Join(", ", allowedValues)}");
+ $"{value} not allowed for parameter {argumentName}, allowed values: {string.Join(", ", allowedValues)}", argumentName);
}
///
@@ -239,7 +239,7 @@ namespace CryptoExchange.Net
{
if (value < minValue || value > maxValue)
throw new ArgumentException(
- $"{value} not allowed for parameter {argumentName}, min: {minValue}, max: {maxValue}");
+ $"{value} not allowed for parameter {argumentName}, min: {minValue}, max: {maxValue}", argumentName);
}
///
@@ -250,7 +250,7 @@ namespace CryptoExchange.Net
public static void ValidateNotNull(this string value, string argumentName)
{
if (string.IsNullOrEmpty(value))
- throw new ArgumentException($"No value provided for parameter {argumentName}");
+ throw new ArgumentException($"No value provided for parameter {argumentName}", argumentName);
}
///
@@ -261,7 +261,7 @@ namespace CryptoExchange.Net
public static void ValidateNotNull(this object value, string argumentName)
{
if (value == null)
- throw new ArgumentException($"No value provided for parameter {argumentName}");
+ throw new ArgumentException($"No value provided for parameter {argumentName}", argumentName);
}
///
@@ -272,7 +272,7 @@ namespace CryptoExchange.Net
public static void ValidateNotNull(this IEnumerable value, string argumentName)
{
if (value == null || !value.Any())
- throw new ArgumentException($"No values provided for parameter {argumentName}");
+ throw new ArgumentException($"No values provided for parameter {argumentName}", argumentName);
}
}
}