Skip to content

Commit 1bceec5

Browse files
committed
Fix tests
1 parent e83ed35 commit 1bceec5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Elastic.Documentation/AppliesTo/Applicability.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System.Collections;
66
using System.Diagnostics.CodeAnalysis;
7+
using System.Linq;
78
using System.Text;
89
using Elastic.Documentation.Diagnostics;
910
using YamlDotNet.Serialization;
@@ -170,8 +171,12 @@ public static explicit operator Applicability(string b)
170171
{
171172
var diagnostics = new List<(Severity, string)>();
172173
var productAvailability = TryParse(b, diagnostics, out var version) ? version : TryParse(b + ".0", diagnostics, out version) ? version : null;
173-
if (diagnostics.Count > 0)
174-
throw new ArgumentException("Explicit conversion from string to AppliesCollection failed." + string.Join(Environment.NewLine, diagnostics));
174+
175+
// Only throw exceptions for errors, not warnings
176+
var errors = diagnostics.Where(d => d.Item1 == Severity.Error).ToList();
177+
if (errors.Count > 0)
178+
throw new ArgumentException("Explicit conversion from string to AppliesCollection failed." + string.Join(Environment.NewLine, errors.Select(e => e.Item2)));
179+
175180
return productAvailability ?? throw new ArgumentException($"'{b}' is not a valid applicability string.");
176181
}
177182

0 commit comments

Comments
 (0)