Skip to content

Commit f26ec59

Browse files
arturcicCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 29ddb17 commit f26ec59

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/GitVersion.Configuration/ConfigurationSerializer.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ public T Deserialize<T>(string input)
2727
{
2828
return (T)(object)YamlSerializer.Deserialize<GitVersionConfiguration>(input, GeneratedContext)!;
2929
}
30-
catch (YamlException)
31-
{
32-
throw;
33-
}
3430
catch (Exception exception)
3531
{
36-
throw new YamlException(exception.Message);
32+
if (exception is YamlException)
33+
{
34+
throw;
35+
}
36+
37+
throw new YamlException(exception.Message, exception);
3738
}
3839
}
3940

src/GitVersion.Configuration/VersionStrategiesConverter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public override VersionStrategies[] Read(YamlReader reader)
2626
throw new YamlException(reader.SourceName, reader.Start, reader.End, "Expected a scalar value while reading version strategies.");
2727
}
2828

29-
strategies.Add(ParseStrategy(reader.GetScalarValue()));
29+
strategies.Add(ParseStrategy(reader, reader.GetScalarValue()));
3030
reader.Read();
3131
}
3232

@@ -44,7 +44,7 @@ public override VersionStrategies[] Read(YamlReader reader)
4444

4545
foreach (var item in SplitScalarList(scalar))
4646
{
47-
strategies.Add(ParseStrategy(item));
47+
strategies.Add(ParseStrategy(reader, item));
4848
}
4949

5050
return [.. strategies];
@@ -82,7 +82,7 @@ private static IEnumerable<string> SplitScalarList(string scalar)
8282
}
8383
}
8484

85-
private static VersionStrategies ParseStrategy(string value)
85+
private static VersionStrategies ParseStrategy(YamlReader reader, string value)
8686
{
8787
if (Enum.TryParse<VersionStrategies>(value, ignoreCase: false, out var exactMatch))
8888
{
@@ -95,7 +95,7 @@ private static VersionStrategies ParseStrategy(string value)
9595
return normalizedMatch;
9696
}
9797

98-
throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown version strategy value.");
98+
throw new YamlException(reader.SourceName, reader.Start, reader.End, $"Unknown version strategy value '{value}'.");
9999
}
100100

101101
private static string Normalize(string value)

0 commit comments

Comments
 (0)