refactor(StringExtensions): Fehlermeldungen wurden ausgearbeitet und der falsche Variablenname „mode“ wurde in „divisor“ umbenannt.
This commit is contained in:
parent
d7b4c382cd
commit
66ed34b664
@ -37,20 +37,20 @@
|
|||||||
var subStrings = format.Split("//");
|
var subStrings = format.Split("//");
|
||||||
|
|
||||||
if (subStrings.Length != 2)
|
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]);
|
var formattedLeft = date.ToString(subStrings[0]);
|
||||||
|
|
||||||
if (!int.TryParse(formattedLeft, out var dateValue))
|
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))
|
if (!int.TryParse(subStrings[1], out var divisor))
|
||||||
throw new FormatException("The right-side value of the format could not be parsed to an integer.");
|
throw new FormatException($"The right-side value ({divisor}) of the format could not be parsed to an integer.");
|
||||||
|
|
||||||
if (mode == 0)
|
if (divisor == 0)
|
||||||
throw new DivideByZeroException("Division by zero is not allowed.");
|
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();
|
return result.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user