Skip to content

A Swiss Army knife for developers.

Updated ValueOverflow exception to use localised error message. (#198)

Tom Gionfriddo92d1a976ddc5
diff --git a/src/dev/impl/DevToys/Strings/en-US/NumberBaseConverter.resw b/src/dev/impl/DevToys/Strings/en-US/NumberBaseConverter.resw
index a30a13e7d..1c99901ee 100644
--- a/src/dev/impl/DevToys/Strings/en-US/NumberBaseConverter.resw
+++ b/src/dev/impl/DevToys/Strings/en-US/NumberBaseConverter.resw
@@ -148,7 +148,7 @@
<value>Decimal</value>
</data>
<data name="InputTypeDescription" xml:space="preserve">
- <value>Select which Input type you want to use</value>
+ <value>Select which input type you want to use</value>
</data>
<data name="InputTypeHexadecimal" xml:space="preserve">
<value>Hexadecimal</value>
@@ -167,7 +167,7 @@
<comment>The parameter is the Base Number Type (Decimal, Octal, ...)</comment>
</data>
<data name="ValueOverflow" xml:space="preserve">
- <value>Unable to parse the current value exceed max value {0}</value>
+ <value>The current value cannot be converted as it exceeds the maximum value ({0})</value>
<comment>The parameter is the Max value of a long</comment>
</data>
<data name="Description" xml:space="preserve">
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Converters/NumberBaseConverter/NumberBaseFormatter.cs b/src/dev/impl/DevToys/ViewModels/Tools/Converters/NumberBaseConverter/NumberBaseFormatter.cs
index 9b413b8a4..c465585d8 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/Converters/NumberBaseConverter/NumberBaseFormatter.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/Converters/NumberBaseConverter/NumberBaseFormatter.cs
@@ -222,14 +222,14 @@ namespace DevToys.Core.Formatter
// Check for overflows - this is sufficient & correct.
if (result > maxVal)
{
- throw new OverflowException($"Unable to parse the current value exceded max value ({long.MaxValue})");
+ throw new OverflowException(string.Format(Strings.ValueOverflow, long.MaxValue));
}
ulong temp = result * (ulong)baseNumber.BaseNumber + (ulong)current;
if (temp < result) // this means overflow as well
{
- throw new OverflowException($"Unable to parse the current value exceded max value ({long.MaxValue})");
+ throw new OverflowException(string.Format(Strings.ValueOverflow, long.MaxValue));
}
result = temp;