我正在尝试创建评估表达式并将错误作为错误字符串返回的代码:
(cond-expand
(gambit)
(gauche)
(kawa)
(guile
(import (rnrs base)
(rnrs exceptions)
(rnrs conditions))
(define (error-object-message cond)
(condition-message cond))))
(define (evaluate expr env)
(call-with-current-continuation
(lambda (exit)
(with-exception-handler
(lambda (e)
(exit (error-object-message e)))
(lambda ()
(eval expr env))))))
;; trigger error
(display (evaluate 'xxx (interaction-environment)))
(newline)
我有
- Guile 消息
Unbound variable: ~S
如何获取实际的错误消息而不是模板? - 卡瓦例外:
Argument #1 'unbound location: xxx' to 'error-object-message' has wrong type (gnu.mapping.UnboundLocationException) (gnu.mapping.UnboundLocationException cannot be cast to kawa.lang.NamedException)
- Gauche 核心转储
- 开局冻结
注意:这是 REPL 的一部分,我正在系统上的所有 Scheme 实现中测试它。它几乎可以工作,它可以自行运行,但我想在发生异常时显示正确的错误消息,而不是退出 REPL。