|
2 | 2 | "# Collection of Tests for Try", |
3 | 3 | { |
4 | 4 | "description": "Coalesce an error", |
5 | | - "rule": { "try": [{ "error": "Some error" }, 1] }, |
| 5 | + "rule": { "try": [{ "throw": "Some error" }, 1] }, |
6 | 6 | "result": 1, |
7 | 7 | "data": null |
8 | 8 | }, |
|
14 | 14 | }, |
15 | 15 | { |
16 | 16 | "description": "Try is variadic", |
17 | | - "rule": { "try": [{ "error": "Some error" }, { "/": [0, 0] }, 2] }, |
| 17 | + "rule": { "try": [{ "throw": "Some error" }, { "/": [0, 0] }, 2] }, |
18 | 18 | "result": 2, |
19 | 19 | "data": null |
20 | 20 | }, |
21 | 21 | { |
22 | 22 | "description": "Panics if none of the values are valid", |
23 | | - "rule": { "try": [{ "error": "Some error" }, { "error": "Some other error" }] }, |
| 23 | + "rule": { "try": [{ "throw": "Some error" }, { "throw": "Some other error" }] }, |
24 | 24 | "error": true, |
25 | 25 | "data": null |
26 | 26 | }, |
27 | 27 | { |
28 | 28 | "description": "Panics if none of the values are valid (2)", |
29 | | - "rule": { "try": [{ "error": "Some error" }, { "/": [0, 0] }] }, |
| 29 | + "rule": { "try": [{ "throw": "Some error" }, { "/": [0, 0] }] }, |
30 | 30 | "error": true, |
31 | 31 | "data": null |
32 | 32 | }, |
|
38 | 38 | }, |
39 | 39 | { |
40 | 40 | "description": "Panics when the only argument is an error", |
41 | | - "rule": { "try": { "error": "Some error" } }, |
| 41 | + "rule": { "try": { "throw": "Some error" } }, |
42 | 42 | "error": true, |
43 | 43 | "data": null |
44 | 44 | }, |
|
56 | 56 | }, |
57 | 57 | { |
58 | 58 | "description": "Panic based on an error emitted from an if", |
59 | | - "rule": { "try": [{ "if": [{"val": ["user", "admin"]}, true, { "error": "Not an admin" }] }] }, |
| 59 | + "rule": { "try": [{ "if": [{"val": ["user", "admin"]}, true, { "throw": "Not an admin" }] }] }, |
60 | 60 | "data": { "user": { "admin": false } }, |
61 | 61 | "error": true |
62 | 62 | }, |
|
78 | 78 | "description": "The context switches for the try coalescing to the previous error", |
79 | 79 | "rule": { |
80 | 80 | "try": [ |
81 | | - { "error": "Some error" }, |
| 81 | + { "throw": "Some error" }, |
82 | 82 | { "val": "error" } |
83 | 83 | ] |
84 | 84 | }, |
|
89 | 89 | "description": "The context switches for the try coalescing to the previous error (2)", |
90 | 90 | "rule": { |
91 | 91 | "try": [ |
92 | | - { "if": [true, { "error": "Some error" }, null] }, |
| 92 | + { "if": [true, { "throw": "Some error" }, null] }, |
93 | 93 | { "val": "error" } |
94 | 94 | ] |
95 | 95 | }, |
|
100 | 100 | "description": "The context switches for the try coalescing to the previous error (3)", |
101 | 101 | "rule": { |
102 | 102 | "try": [ |
103 | | - { "error": "A" }, |
104 | | - { "error": "B" }, |
| 103 | + { "throw": "A" }, |
| 104 | + { "throw": "B" }, |
105 | 105 | { "val": "error" } |
106 | 106 | ] |
107 | 107 | }, |
|
111 | 111 | { |
112 | 112 | "description": "Error can pull from an error object", |
113 | 113 | "rule": { |
114 | | - "try": [{ "error": { "val": "x" } }, { "val": "error" }] |
| 114 | + "try": [{ "throw": { "val": "x" } }, { "val": "error" }] |
115 | 115 | }, |
116 | 116 | "data": { "x": { "error": "Some error" }}, |
117 | 117 | "result": "Some error" |
|
134 | 134 | "description": "Handles NaN Explicitly", |
135 | 135 | "rule": { |
136 | 136 | "try": [ |
137 | | - { "if": [{ "/": [1, { "val": "x" }] }, { "error": "Some error" }, null] }, |
| 137 | + { "if": [{ "/": [1, { "val": "x" }] }, { "throw": "Some error" }, null] }, |
138 | 138 | { |
139 | | - "if": [{ "===": [{ "val": "error" }, "NaN"]}, "Handled", { "error": { "val": [] } }] |
| 139 | + "if": [{ "===": [{ "val": "error" }, "NaN"]}, "Handled", { "throw": { "val": [] } }] |
140 | 140 | } |
141 | 141 | ] |
142 | 142 | }, |
|
147 | 147 | "description": "Did not NaN, so it errored", |
148 | 148 | "rule": { |
149 | 149 | "try": [ |
150 | | - { "if": [{ "/": [1, { "val": "x" }] }, { "error": "Some error" }, null] }, |
151 | | - { "if": [{ "===": [{ "val": "error" }, "NaN"]}, "Handled", { "error": { "val": [] } }] } |
| 150 | + { "if": [{ "/": [1, { "val": "x" }] }, { "throw": "Some error" }, null] }, |
| 151 | + { "if": [{ "===": [{ "val": "error" }, "NaN"]}, "Handled", { "throw": { "val": [] } }] } |
152 | 152 | ] |
153 | 153 | }, |
154 | 154 | "error": true, |
|
0 commit comments