You can just use the very useful pr-str
function from clojure.core
:
(catch Exception e
(l/error "Ho no, an exception:" (pr-str e)))
#error {
:cause nil
:via
[{:type java.lang.NullPointerException
:message nil
:at [my_app$fn__47429$fn__47430 invoke "my_app.clj" 30]}]
:trace
[[my_app$fn__47429$fn__47430 invoke "my_app.clj" 30]
[my_app$my_func invokeStatic "my_app.clj" 13]
[my_app$my_func invoke "my_app.clj" 10]
[my_app$other_func$fn__29431 invoke "my_app.clj" 19]
[my_app$other_func_BANG_ invokeStatic "my_app.clj" 28]
[my_app$other_func_BANG_ invoke "my_app.clj" 27]
[my_app$yet_another_func invokeStatic "my_app.clj" 40]
[my_app$yet_another_func invoke "my_app.clj" 37]
[clojure.core$fn__8072$fn__8074 invoke "core.clj" 6760]
[clojure.core.protocols$iter_reduce invokeStatic "protocols.clj" 49]
[clojure.core.protocols$fn__7839 invokeStatic "protocols.clj" 75]
[clojure.core.protocols$fn__7839 invoke "protocols.clj" 75]
[clojure.core.protocols$fn__7781$G__7776__7794 invoke "protocols.clj" 13]
[clojure.core$reduce invokeStatic "core.clj" 6748]
[clojure.core$fn__8072 invokeStatic "core.clj" 6750]
[clojure.core$fn__8072 invoke "core.clj" 6750]
[clojure.core.protocols$fn__7860$G__7855__7869 invoke "protocols.clj" 175]
[clojure.core$reduce_kv invokeStatic "core.clj" 6776]
[clojure.core$reduce_kv invoke "core.clj" 6767]
[my_app$yet_another_func invokeStatic "data_streamer.clj" 48]
[my_app$yet_another_func invoke "data_streamer.clj" 47]
[my_app$other_func invokeStatic "data_streamer.clj" 66]
[my_app$other_func invoke "data_streamer.clj" 58]
[my_app$other_func$fn__48385 invoke "my_app.clj" 73]
[clojure.core.async$thread_call$fn__6553 invoke "async.clj" 442]
[clojure.lang.AFn run "AFn.java" 22]
[java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1135]
[java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 635]
[java.lang.Thread run "Thread.java" 844]]}
(apply str (interpose "\n" (.getStackTrace t)))
works really well, too. – Titian