Skip to content

Commit 204303b

Browse files
committed
Remove "throwOnException" parameter on the extensions
1 parent b8ac2cc commit 204303b

2 files changed

Lines changed: 2 additions & 14 deletions

File tree

WebUntisAPI.Client/Extensions/ColorExtensions.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,12 @@ public static string ToHexColorFormat(this Color color)
2828
/// </summary>
2929
/// <param name="color"></param>
3030
/// <param name="colorString">The string to convert</param>
31-
/// <param name="throwOnException">Throw a exception on validation error. When not to throw on exception and an exception happened is the return value <see langword="null"/></param>
3231
/// <returns>The created color</returns>
3332
/// <exception cref="ArgumentException">Thrown when the <paramref name="colorString"/> isn't in the correct format</exception>
34-
public static Color? FromHexColorFormat(this Color color, string colorString, bool throwOnException = true)
33+
public static Color FromHexColorFormat(this Color color, string colorString)
3534
{
3635
if (!Regex.IsMatch(colorString, @"[\da-fA-F]{6}"))
37-
{
38-
if (!throwOnException)
39-
return null;
40-
4136
throw new ArgumentException("The color string isn't in a correct format", nameof(colorString));
42-
}
4337

4438
// Convert the hex string to the single color channels
4539
int red = Convert.ToByte(colorString.Substring(0, 2), 16);

WebUntisAPI.Client/Extensions/DateTimeExtensions.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ public static void ToWebUntisTimeFormat(this DateTime dateTime, out string dateS
4242
/// <param name="dateTime">Instance</param>
4343
/// <param name="dateString">Date string</param>
4444
/// <param name="timeString">Time string</param>
45-
/// <param name="throwOnException">Throw a exception on validation error</param>
4645
/// <returns>The new instance that contains the given time. When not to throw on exception and an exception happened is the return value <see langword="null"/></returns>
4746
/// <exception cref="FormatException">Thrown when one of the given strings isn't in the right format</exception>
48-
public static DateTime? FromWebUntisTimeFormat(this DateTime dateTime, string dateString, string timeString, bool throwOnException = true)
47+
public static DateTime FromWebUntisTimeFormat(this DateTime dateTime, string dateString, string timeString)
4948
{
5049
Regex dateRegex = new Regex(@"^\d{4}-(0\d|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])$"); // Regex for the WebUntis date format
5150
Regex timeRegex = new Regex(@"^(\d|1\d|2[0-3])[0-5]\d$"); // Regex for the WebUntis time format
@@ -55,12 +54,7 @@ public static void ToWebUntisTimeFormat(this DateTime dateTime, out string dateS
5554
bool isTimeValid = timeRegex.IsMatch(timeString);
5655

5756
if (!isDateValid || !isTimeValid)
58-
{
59-
if (!throwOnException)
60-
return null;
61-
6257
throw new FormatException($"The string {(isDateValid ? timeString : dateString)} isn't in the valid format!");
63-
}
6458

6559

6660
// Parse the numbers in the string to value

0 commit comments

Comments
 (0)