开发者

How can I get the call stack in Clojure?

I have a point in my clojure code where I want to know what the call stack was (ie: list of clojure funct开发者_JS百科ions used to get there). How can I do this?


This isn't the nicest solution, but it's simple and it should work in core clojure:

(try (throw (Exception. "")) (catch Exception e (.printStackTrace e *out*)))

You can inspect e in code if you want something other than a printed version. See also clojure.stacktrace in the current master branch or clj-stacktrace for clojure 1.2.


clojure.repl contains pst.

Example:

(pst (Exception. "") nr-lines
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜