(try
(/ 1 0)
(catch Exception e
(prn e)))
以REPL打印
#error {
:cause Divide by zero
:via
[{:type java.lang.ArithmeticException
:message Divide by zero
:at [clojure.lang.Numbers divide Numbers.java 158]}]
:trace
[[clojure.lang.Numbers divide Numbers.java 158]
......................
[java.lang.Thread run Thread.java 745]]}
如何使用str获取这个完整且易于理解的消息?
(try
(/ 1 0)
(catch Exception e
(str e)))
仅返回
=> "java.lang.ArithmeticException: Divide by zero"
答案 0 :(得分:2)
解决方案非常简单
(pr-str e)