diff --git a/DigitalData.Core.Security/Config/StringExtensions.cs b/DigitalData.Core.Security/Config/StringExtensions.cs index 889075f..111dfbb 100644 --- a/DigitalData.Core.Security/Config/StringExtensions.cs +++ b/DigitalData.Core.Security/Config/StringExtensions.cs @@ -37,20 +37,20 @@ var subStrings = format.Split("//"); if (subStrings.Length != 2) - throw new ArgumentException("Format is invalid. It must contain exactly one '//' separator."); + throw new ArgumentException($"Date tag format {format} is invalid. It must contain exactly one '//' separator.", nameof(format)); var formattedLeft = date.ToString(subStrings[0]); if (!int.TryParse(formattedLeft, out var dateValue)) - throw new FormatException("The left-side value of the format could not be parsed to an integer."); + throw new FormatException($"The left-side value ({formattedLeft}) of the format could not be parsed to an integer."); - if (!int.TryParse(subStrings[1], out var mode)) - throw new FormatException("The right-side value of the format could not be parsed to an integer."); + if (!int.TryParse(subStrings[1], out var divisor)) + throw new FormatException($"The right-side value ({divisor}) of the format could not be parsed to an integer."); - if (mode == 0) - throw new DivideByZeroException("Division by zero is not allowed."); + if (divisor == 0) + throw new DivideByZeroException($"Date tag format {format} includes division by zero, which is not allowed."); - var result = (dateValue - 1) / mode + 1; + var result = (dateValue - 1) / divisor + 1; return result.ToString(); }