Permalink
Browse files

make 'pst' accept parsed exceptions

1 parent a47a2c9 commit b4143975a4126e581b536332f28af8e1c2f73ab7 @gerrit-hntschl gerrit-hntschl committed May 22, 2014
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/clj_stacktrace/repl.clj
View
9 src/clj_stacktrace/repl.clj
@@ -109,9 +109,12 @@
this-source-width))) this-source-width)))
(defn pst-on [on color? e] (defn pst-on [on color? e]
- "Prints to the given Writer on a pretty stack trace for the given exception e, + "Prints to the given Writer on a pretty stack trace for e which can be an exception
+ or already parsed exception (clj-stacktrace.core/parse-exception).
ANSI colored if color? is true." ANSI colored if color? is true."
- (let [exec (parse-exception e) + (let [exec (if (instance? Throwable e)
+ (parse-exception e)
+ e)
source-width (find-source-width exec)] source-width (find-source-width exec)]
(pst-class-on on color? (:class exec)) (pst-class-on on color? (:class exec))
(pst-message-on on color? (:message exec)) (pst-message-on on color? (:message exec))
@@ -120,7 +123,7 @@
(pst-cause-on on color? cause source-width)))) (pst-cause-on on color? cause source-width))))
(defn pst (defn pst
- "Print to *out* a pretty stack trace for an exception, by default *e." + "Print to *out* a pretty stack trace for a (parsed) exception, by default *e."
[& [e]] [& [e]]
(pst-on *out* false (or e *e))) (pst-on *out* false (or e *e)))

0 comments on commit b414397

Please sign in to comment.