Debian Codegraph @

hitch/story/handle-exceptions.story

raw
1 Labeling exceptions:
2 docs: howto/label-exceptions
3 based on: strictyaml
4 description: |
5 When raising exceptions, you can add a label that will replace
6 <unicode string> with whatever you want.
7 given:
8 setup: |
9 from strictyaml import Map, Int, load, YAMLValidationError
10 yaml_snippet: |
11 a: 1
12 b:
13 - 1
14 - 2
15 variations:
16 Label myfilename:
17 steps:
18 - Run:
19 code: |
20 load(yaml_snippet, Map({"a": Int(), "b": Map({"x": Int(), "y": Int()})}), label="myfilename")
21 raises:
22 type: strictyaml.exceptions.YAMLValidationError
23 message: |-
24 when expecting a mapping
25 in "myfilename", line 2, column 1:
26 b:
27 ^ (line: 2)
28 found a sequence
29 in "myfilename", line 4, column 1:
30 - '2'
31 ^ (line: 4)