ClojureDocs

Nav

Namespaces

Throwable->map

clojure.core

Available since 1.7 (source)
  • (Throwable->map o)
Constructs a data representation for a Throwable with keys:
  :cause - root cause message
  :phase - error phase
  :via - cause chain, with cause keys:
           :type - exception class symbol
           :message - exception message
           :data - ex-data
           :at - top stack element
  :trace - root cause stack elements
1 Example
(def trace (try (/ 1 0) (catch Throwable t (Throwable->map t))))
(keys trace)
;; (:cause :via :trace)
(:cause trace)
;; "Divide by zero"
(count (:trace trace))
;; 33 (this stack trace is 33 invocations deep) 
See Also

Returns exception data (a map) if ex is an IExceptionInfo. Otherwise returns nil.

Added by cljlc
0 Notes
No notes for Throwable->map