Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 0f577bd

Browse files
authored
Add detailed example for rethrow to explainer (#263)
The current explainer has a detailed example on `delegate`, which was adapted from #146 (comment), but not the one for `rethrow` from the same issue (#146 (comment)). This adds the detailed `rethrow` example to the explainer, with the some cosmetic changes to the label names and comments.
1 parent e987be4 commit 0f577bd

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

proposals/exception-handling/Exceptions.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,41 @@ end
257257
The `rethrow` here references `try $l2`, but the `rethrow` is not within its
258258
`catch` block.
259259

260+
The example below includes all of the cases explained above. The numbers
261+
within `()` after `rethrow`s are the label operands in immediate values.
262+
```
263+
(func $test
264+
try $lA
265+
...
266+
catch ($lA)
267+
...
268+
block $lB
269+
...
270+
try $lC
271+
...
272+
catch ($lC)
273+
...
274+
try $lD
275+
...
276+
rethrow $lD (0) ;; refers to 'catch ($lD)', but it is not within 'catch ($lD)', so validation failure
277+
rethrow $lC (1) ;; rethrows the exception caught by catch ($lC)
278+
rethrow $lB (2) ;; refers to 'block $lB', so validation failure
279+
rethrow $lA (3) ;; rethrows the exception caught by catch ($lA)
280+
rethrow 4 ;; validation failure
281+
catch ($lD)
282+
...
283+
rethrow $lD (0) ;; rethrows the exception caught by catch ($lD)
284+
rethrow $lC (1) ;; rethrows the exception caught by catch ($lC)
285+
rethrow $lB (2) ;; refers to 'block $lB', so validation failure
286+
rethrow $lA (3) ;; rethrows the exception caught by catch ($lA)
287+
rethrow 4 ;; validation failure
288+
end
289+
end
290+
end
291+
...
292+
end
293+
```
294+
260295
### Try-delegate blocks
261296

262297
Try blocks can also be used with the `delegate` instruction. A try-delegate

0 commit comments

Comments
 (0)