如何在球拍中实现try-catch块?
我尝试在球拍中写下try-catch
块,从提供的样板中,提供在这里,但是当我运行时,它会给我带来错误。
try-catch
块:
#lang racket
(require try-catch-match)
(try [(displayln "body")
(raise 'boom)]
[catch (string? (printf "caught a string: ~v\n" e))
(symbol? (printf "'e' (the value of the exception) is: ~v\n" e))])
引发此错误:
< img src =“ https://i.sstatic.net/6acoz.jpg” alt =“在此处输入图像说明”>
它说语法错误,但我真的看不到任何问题。该代码来自官方球拍网站。我的目标是在球拍中写一个简单的try-catch
块,大概是使用导入的库。
I try to write a try-catch
block in racket, from the boilerplate provided here, however when I run it throws me an error.
try-catch
block:
#lang racket
(require try-catch-match)
(try [(displayln "body")
(raise 'boom)]
[catch (string? (printf "caught a string: ~v\n" e))
(symbol? (printf "'e' (the value of the exception) is: ~v\n" e))])
Throws this error:
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要 try-catch-match-match 库,但是您的示例来自 try-catch 库。这两个是不同的,如果您使用正确的一个,则示例代码将有效:
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: