Skip to content
Browse files

Factor out printing aligned frames

  • Loading branch information...
1 parent 2e3db37 commit 0d9918b9813af1f92fec5be91a5873e73976233c @derekmansen derekmansen committed Dec 18, 2011
Showing with 8 additions and 5 deletions.
  1. +8 −5 src/clj_stacktrace/repl.clj
View
13 src/clj_stacktrace/repl.clj
@@ -56,6 +56,12 @@
(.append on "\n")
(.flush on))
+(defn pst-elem-str
+ [color? parsed-elem print-width]
+ (colored color? (elem-color parsed-elem)
+ (str (utils/rjust print-width (source-str parsed-elem))
+ " " (method-str parsed-elem))))
+
(defn pst-elems-on
[on color? parsed-elems & [source-width]]
(let [print-width (+ 6 (or source-width
@@ -64,10 +70,7 @@
(map #(.length %)
(map source-str parsed-elems))))))]
(doseq [parsed-elem parsed-elems]
- (.append on
- (colored color? (elem-color parsed-elem)
- (str (utils/rjust print-width (source-str parsed-elem))
- " " (method-str parsed-elem))))
+ (.append on (pst-elem-str color? parsed-elem print-width))
(.append on "\n")
(.flush on))))
@@ -85,7 +88,7 @@
(if-let [cause (:cause exec)]
(pst-cause-on on color? cause source-width)))
-(defn- find-source-width
+(defn find-source-width
"Returns the width of the longest source-string among all trace elems of the
excp and its causes."
[excp]

0 comments on commit 0d9918b

Please sign in to comment.
Something went wrong with that request. Please try again.