@@ -34,7 +34,7 @@ public enum JsonPathOp
3434/// </summary>
3535/// <remarks>
3636/// For <see cref="XchangeResultType.Error"/> groups the content is the exception stack-trace text.
37- /// For <see cref="XchangeResultType.BadResult"/> groups the content is the raw JSON response string .
37+ /// For <see cref="XchangeResultType.BadResult"/> groups the content is the raw response body .
3838/// Matcher implementations are serialised polymorphically via <c>System.Text.Json</c>.
3939/// </remarks>
4040[ JsonPolymorphic ( TypeDiscriminatorPropertyName = "type" ) ]
@@ -44,8 +44,13 @@ public enum JsonPathOp
4444[ JsonDerivedType ( typeof ( JsonPathMatcher ) , typeDiscriminator : "jsonPath" ) ]
4545public abstract class Matcher
4646{
47- /// <summary>The result type this matcher operates on.</summary>
48- public abstract XchangeResultType ResultType { get ; }
47+ /// <summary>
48+ /// Returns <c>true</c> when this matcher can be evaluated against
49+ /// <paramref name="resultType"/> content. The evaluator skips incompatible matchers,
50+ /// so a group whose matchers all return <c>false</c> here can never fire for that
51+ /// result type.
52+ /// </summary>
53+ public abstract bool Supports ( XchangeResultType resultType ) ;
4954
5055 /// <summary>
5156 /// Returns <c>true</c> when <paramref name="content"/> satisfies this matcher's condition.
@@ -54,16 +59,17 @@ public abstract class Matcher
5459 public abstract bool IsMatch ( string content ) ;
5560}
5661
57- // ── Error matchers ───────────────────── ───────────────────────────────────────
62+ // ── Text matchers (Error and BadResult) ───────────────────────────────────────
5863
5964/// <summary>
60- /// Matches when the exception text contains a literal substring.
61- /// Applies to <see cref="XchangeResultType.Error"/> content .
65+ /// Matches when the failure text contains a literal substring — the exception text for
66+ /// <see cref="XchangeResultType.Error"/>, the response body for <see cref="XchangeResultType.BadResult"/> .
6267/// </summary>
6368public class ContainsMatcher : Matcher
6469{
6570 /// <inheritdoc/>
66- public override XchangeResultType ResultType => XchangeResultType . Error ;
71+ public override bool Supports ( XchangeResultType resultType ) =>
72+ resultType is XchangeResultType . Error or XchangeResultType . BadResult ;
6773
6874 /// <summary>The substring to search for.</summary>
6975 public required string Value { get ; init ; }
@@ -78,13 +84,14 @@ public override bool IsMatch(string content) =>
7884}
7985
8086/// <summary>
81- /// Matches when the exception text satisfies a regular expression.
82- /// Applies to <see cref="XchangeResultType.Error"/> content .
87+ /// Matches when the failure text satisfies a regular expression — the exception text for
88+ /// <see cref="XchangeResultType.Error"/>, the response body for <see cref="XchangeResultType.BadResult"/> .
8389/// </summary>
8490public class RegexMatcher : Matcher
8591{
8692 /// <inheritdoc/>
87- public override XchangeResultType ResultType => XchangeResultType . Error ;
93+ public override bool Supports ( XchangeResultType resultType ) =>
94+ resultType is XchangeResultType . Error or XchangeResultType . BadResult ;
8895
8996 /// <summary>.NET-compatible regular expression pattern.</summary>
9097 public required string Pattern { get ; init ; }
@@ -106,6 +113,8 @@ public class RegexMatcher : Matcher
106113 public override bool IsMatch ( string content ) => Compiled . IsMatch ( content ) ;
107114}
108115
116+ // ── Error-only matcher ────────────────────────────────────────────────────────
117+
109118/// <summary>
110119/// Matches when the exception text mentions a specific .NET exception type name,
111120/// scanning the entire stack-trace including inner exceptions.
@@ -118,7 +127,8 @@ public class RegexMatcher : Matcher
118127public class ExceptionTypeMatcher : Matcher
119128{
120129 /// <inheritdoc/>
121- public override XchangeResultType ResultType => XchangeResultType . Error ;
130+ public override bool Supports ( XchangeResultType resultType ) =>
131+ resultType == XchangeResultType . Error ;
122132
123133 /// <summary>
124134 /// Fully-qualified or short exception type name, e.g. <c>"System.TimeoutException"</c>
@@ -163,7 +173,8 @@ public override bool IsMatch(string content)
163173public class JsonPathMatcher : Matcher
164174{
165175 /// <inheritdoc/>
166- public override XchangeResultType ResultType => XchangeResultType . BadResult ;
176+ public override bool Supports ( XchangeResultType resultType ) =>
177+ resultType == XchangeResultType . BadResult ;
167178
168179 /// <summary>JSONPath expression, e.g. <c>"$.error.code"</c> or <c>"$.lines[0].status"</c>.</summary>
169180 public required string Path { get ; init ; }
0 commit comments