Skip to content

Commit c238aa1

Browse files
authored
Add YAML spec docs about matching errors (#89370)
It's not obvious that a YAML test with a `catch` stanza also permits `match` blocks to assert things about the structure of the error response, but this structure may be an important part of the API spec. This commit adds this info to the docs about YAML tests.
1 parent 1403ab3 commit c238aa1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/README.asciidoc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,15 @@ be caught and tested. For instance:
320320
catch: missing
321321
get:
322322
index: test
323-
type: test
323+
type: test
324324
id: 1
325+
326+
# And, optionally, you can assert on the contents of the precise contents of the error message:
327+
328+
- match: { error.type: "illegal_argument_exception" }
329+
- match: { error.reason: "The request contained an illegal argument" }
330+
- match: { error.caused_by.reason: "The argument was illegal because ..." }
331+
- match: { error.root_cause.0.type: "illegal_argument_exception" }
325332
....
326333
327334
The argument to `catch` can be any of:

0 commit comments

Comments
 (0)