I try to write a try-catch
block in racket, from the boilerplate provided
It says syntax error, but I really cannot see any issues. The code is from the official racket website. My goal is to write a simple try-catch
block in racket, presumably using the imported library.
CodePudding user response:
You're requiring try-catch-match library, but your example comes from try-catch library. These two are different and if you use the correct one, the example code will work:
#lang racket
(require try-catch)
(try [(displayln "body")
(raise 'boom)]
[catch (string? (printf "caught a string\n"))
(symbol? (printf "caught a symbol\n"))])