Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexknauth/try-catch-finally
A racket macro for catching exceptions and running teardown operations.
https://github.com/alexknauth/try-catch-finally
Last synced: about 1 month ago
JSON representation
A racket macro for catching exceptions and running teardown operations.
- Host: GitHub
- URL: https://github.com/alexknauth/try-catch-finally
- Owner: AlexKnauth
- License: other
- Created: 2021-07-27T19:06:51.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-07-29T17:08:35.000Z (over 3 years ago)
- Last Synced: 2024-05-23T00:11:42.134Z (8 months ago)
- Language: Racket
- Size: 7.81 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
try-catch-finally
=================
A macro for catching exceptions and running teardown operations.Documentation: https://docs.racket-lang.org/try-catch-finally/index.html
```scheme
(try
body ...+
catch-clause ...
maybe-finally-clause)catch-clause = (catch pred => handler)
| (catch (pred id) handler-body ...+)
| (catch (id) handler-body ...+)
| (catch _ handler-body ...+)maybe-finally-clause =
| (finally post-body ...+)
```Examples:
```scheme
> (try
(raise-syntax-error #f "a syntax error")
(catch (exn:fail:syntax? e)
(displayln "got a syntax error")))
got a syntax error
> (try
(raise-syntax-error #f "a syntax error")
(catch (exn:fail:syntax? e)
(displayln "got a syntax error"))
(catch (exn:fail? e)
(displayln "fallback clause")))
got a syntax error
> (try
(displayln "at")
(finally (displayln "out")))
at
out
> (let/cc up
(try
(displayln "at before")
(up (void))
(displayln "at after")
(finally (displayln "out"))))
at before
out
```