Skip to content

Commit

Permalink
Add detailed example for rethrow to explainer (#263)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aheejin authored Feb 23, 2023
1 parent e987be4 commit 0f577bd
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions proposals/exception-handling/Exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,41 @@ end
The `rethrow` here references `try $l2`, but the `rethrow` is not within its
`catch` block.

The example below includes all of the cases explained above. The numbers
within `()` after `rethrow`s are the label operands in immediate values.
```
(func $test
try $lA
...
catch ($lA)
...
block $lB
...
try $lC
...
catch ($lC)
...
try $lD
...
rethrow $lD (0) ;; refers to 'catch ($lD)', but it is not within 'catch ($lD)', so validation failure
rethrow $lC (1) ;; rethrows the exception caught by catch ($lC)
rethrow $lB (2) ;; refers to 'block $lB', so validation failure
rethrow $lA (3) ;; rethrows the exception caught by catch ($lA)
rethrow 4 ;; validation failure
catch ($lD)
...
rethrow $lD (0) ;; rethrows the exception caught by catch ($lD)
rethrow $lC (1) ;; rethrows the exception caught by catch ($lC)
rethrow $lB (2) ;; refers to 'block $lB', so validation failure
rethrow $lA (3) ;; rethrows the exception caught by catch ($lA)
rethrow 4 ;; validation failure
end
end
end
...
end
```

### Try-delegate blocks

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

0 comments on commit 0f577bd

Please sign in to comment.