Skip to content

Commit

Permalink
Add detailed example for rethrow to explainer
Browse files Browse the repository at this point in the history
The current explainer has a detailed example on `delegate`, which was
adapted from
WebAssembly#146 (comment),
but not the one for `rethrow` from the same issue
(WebAssembly#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 committed Feb 18, 2023
1 parent a34d5f9 commit 97a13bb
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 below is an example that includes all the cases explained. 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 97a13bb

Please sign in to comment.