From c6f550d5a731c5df63f26a3f1e57175eda4d47f7 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Fri, 2 Apr 2021 12:40:55 +0100 Subject: [PATCH] (#27) Move bounds exception to resource --- X10D/src/ComparableExtensions/ComparableExtensions.cs | 4 +++- X10D/src/ExceptionMessages.Designer.cs | 9 +++++++++ X10D/src/ExceptionMessages.resx | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/X10D/src/ComparableExtensions/ComparableExtensions.cs b/X10D/src/ComparableExtensions/ComparableExtensions.cs index 1ccecd9..d314c13 100644 --- a/X10D/src/ComparableExtensions/ComparableExtensions.cs +++ b/X10D/src/ComparableExtensions/ComparableExtensions.cs @@ -79,7 +79,9 @@ namespace X10D.ComparableExtensions { if (lower.GreaterThan(upper)) { - throw new ArgumentException($@"{lower} cannot be greater than {upper}", nameof(lower)); + throw new ArgumentException( + string.Format(ExceptionMessages.LowerCannotBeGreaterThanUpper, lower, upper), + nameof(lower)); } return value.Max(lower).Min(upper); diff --git a/X10D/src/ExceptionMessages.Designer.cs b/X10D/src/ExceptionMessages.Designer.cs index 0e6da91..ed682a4 100644 --- a/X10D/src/ExceptionMessages.Designer.cs +++ b/X10D/src/ExceptionMessages.Designer.cs @@ -87,6 +87,15 @@ namespace X10D { } } + /// + /// Looks up a localized string similar to {0} cannot be greater than {1}. + /// + internal static string LowerCannotBeGreaterThanUpper { + get { + return ResourceManager.GetString("LowerCannotBeGreaterThanUpper", resourceCulture); + } + } + /// /// Looks up a localized string similar to maxValue must be greater than or equal to 0. /// diff --git a/X10D/src/ExceptionMessages.resx b/X10D/src/ExceptionMessages.resx index c3f36f9..76f5df6 100644 --- a/X10D/src/ExceptionMessages.resx +++ b/X10D/src/ExceptionMessages.resx @@ -53,4 +53,7 @@ maxValue must be greater than or equal to minValue + + {0} cannot be greater than {1} + \ No newline at end of file