unison/unison-src/transcripts/top-level-exceptions.md
Greg Pfeil 75c228f4e1
Use CommonMark-compatible info strings everywhere
The bulk of this updates transcripts to put spaces around the language
name in code blocks. E.g.,
```` markdown
```ucm:hide
````
becomes
```` markdown
``` ucm :hide
````

This corresponds to
https://share.unison-lang.org/@unison/website/contributions/11, which
updates the docs in the same way.

This is effectively a fix for #5214, but that issue also has good recommendations for future changes to info strings, so
I don’t know that it should be closed.
2024-10-08 14:23:34 -06:00

46 lines
863 B
Markdown

A simple transcript to test the use of exceptions that bubble to the top level.
``` ucm :hide
scratch/main> builtins.merge
```
FYI, here are the `Exception` and `Failure` types:
``` ucm
scratch/main> view Exception Failure
```
Here's a sample program just to verify that the typechecker allows `run` to throw exceptions:
``` unison
use builtin IO Exception Test.Result
main : '{IO, Exception} ()
main _ = ()
mytest : '{IO, Exception} [Test.Result]
mytest _ = [Ok "Great"]
```
``` ucm
scratch/main> run main
scratch/main> add
scratch/main> io.test mytest
```
Now a test to show the handling of uncaught exceptions:
``` unison
main2 = '(error "oh noes!" ())
error : Text -> a ->{Exception} x
error msg a =
builtin.Exception.raise (Failure (typeLink RuntimeError) msg (Any a))
unique type RuntimeError =
```
``` ucm :error
scratch/main> run main2
```