Permalink
Browse files

Include ex-data in parsed exceptions. Requires Clojure 1.4.x

  • Loading branch information...
1 parent 1a417ec commit 5c8ea286d39243de9ddc65b91b0fa4ba3035f8f3 @Chouser Chouser committed Mar 26, 2012
Showing with 11 additions and 7 deletions.
  1. +1 −1 project.clj
  2. +10 −6 src/clj_stacktrace/core.clj
View
@@ -1,5 +1,5 @@
(defproject clj-stacktrace "0.2.5-SNAPSHOT"
:description "More readable stacktraces in Clojure programs."
:url "http://github.com/mmcgrana/clj-stacktrace"
- :dev-dependencies [[org.clojure/clojure "1.2.1"]
+ :dev-dependencies [[org.clojure/clojure "1.4.0-alpha5"]
[lein-clojars "0.6.0"]])
@@ -105,9 +105,11 @@
:message (.getMessage causer-e)
:trace-elems parsed-elems
:trimmed-elems (trim-redundant parsed-elems caused-parsed-elems)}]
- (if-let [cause (.getCause causer-e)]
- (assoc base :cause (parse-cause-exception cause parsed-elems))
- base)))
+ (conj base
+ (when-let [cause (.getCause causer-e)]
+ [:cause (parse-cause-exception cause parsed-elems)])
+ (when-let [data (ex-data causer-e)]
+ [:data data]))))
(defn parse-exception
"Returns a Clojure map providing usefull informaiton about the exception.
@@ -121,9 +123,11 @@
base {:class (class e)
:message (.getMessage e)
:trace-elems parsed-elems}]
- (if-let [cause (.getCause e)]
- (assoc base :cause (parse-cause-exception cause parsed-elems))
- base)))
+ (conj base
+ (when-let [cause (.getCause e)]
+ [:cause (parse-cause-exception cause parsed-elems)])
+ (when-let [data (ex-data e)]
+ [:data data]))))
(defn cause-seq [e]
"Takes a parsed exception and returns a seq of parsed exception

0 comments on commit 5c8ea28

Please sign in to comment.