Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the call stack in Clojure?

Tags:

clojure

I have a point in my clojure code where I want to know what the call stack was (ie: list of clojure functions used to get there). How can I do this?

like image 761
yazz.com Avatar asked Jul 10 '11 10:07

yazz.com


1 Answers

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.

like image 149
Joost Diepenmaat Avatar answered Oct 25 '22 12:10

Joost Diepenmaat