Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cosmetic changes; mostly trailing whitespace and indentation.

  • Loading branch information...
commit 51cecf8aa992ed457583176a1ea8ce2879cdbc88 1 parent 2fe5526
@technomancy technomancy authored
View
1  .gitignore
@@ -1,2 +1,3 @@
*.jar
*.xml
+/.lein-failures
View
24 src/clj_stacktrace/core.clj
@@ -13,10 +13,10 @@
[class-name]
(utils/re-gsub #"_" "-" (utils/re-get #"([^$]+)\$" class-name 1)))
-; drop everything before and including the first $
-; drop everything after and including and the second $
-; drop any __xyz suffixes
-; sub _PLACEHOLDER_ for the corresponding char
+;; drop everything before and including the first $
+;; drop everything after and including and the second $
+;; drop any __xyz suffixes
+;; sub _PLACEHOLDER_ for the corresponding char
(def clojure-fn-subs
[[#"^[^$]*\$" ""]
[#"\$.*" ""]
@@ -35,9 +35,9 @@
"Returns the clojure function name implied by the bytecode class name."
[class-name]
(reduce
- (fn [base-name [pattern sub]] (utils/re-gsub pattern sub base-name))
- class-name
- clojure-fn-subs))
+ (fn [base-name [pattern sub]] (utils/re-gsub pattern sub base-name))
+ class-name
+ clojure-fn-subs))
(defn- clojure-annon-fn?
"Returns true if the bytecode class name implies an anonymous inner fn."
@@ -47,15 +47,15 @@
(defn parse-trace-elem
"Returns a map of information about the java trace element.
All returned maps have the keys:
- :file String of source file name.
+ :file String of source file name.
:line Number of source line number of the enclosing form.
Additionally for elements from Java code:
- :java true, to indicate a Java elem.
+ :java true, to indicate a Java elem.
:class String of the name of the class to which the method belongs.
Additionally for elements from Clojure code:
- :clojure true, to inidcate a Clojure elem.
+ :clojure true, to inidcate a Clojure elem.
:ns String representing the namespace of the function.
- :fn String representing the name of the enclosing var for the function.
+ :fn String representing the name of the enclosing var for the function.
:annon-fn true iff the function is an anonymous inner fn."
[elem]
(let [class-name (.getClassName elem)
@@ -80,7 +80,7 @@
(map parse-trace-elem elems))
(defn- trim-redundant
- "Returns the portion of the tail of causer-elems that is not duplicated in
+ "Returns the portion of the tail of causer-elems that is not duplicated in
the tail of caused-elems. This corresponds to the \"...26 more\" that you
see at the bottom of regular trace dumps."
[causer-parsed-elems caused-parsed-elems]
View
41 src/clj_stacktrace/repl.clj
@@ -28,15 +28,10 @@
(if (utils/re-match? #"^clojure\." (:class elem))
:cyan
:blue)
- (cond
- (nil? (:ns elem))
- :yellow
- (utils/re-match? #"^(user|repl)" (:ns elem))
- :yellow
- (utils/re-match? #"^clojure\." (:ns elem))
- :magenta
- :user-code
- :green)))
+ (cond (nil? (:ns elem)) :yellow
+ (utils/re-match? #"^(user|repl)" (:ns elem)) :yellow
+ (utils/re-match? #"^clojure\." (:ns elem)) :magenta
+ :user-code :green)))
(defn source-str [parsed]
(if (and (:file parsed) (:line parsed))
@@ -65,14 +60,14 @@
[on color? parsed-elems & [source-width]]
(let [print-width (+ 6 (or source-width
(utils/fence
- (sort
- (map #(.length %)
- (map source-str parsed-elems))))))]
+ (sort
+ (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))))
+ (colored color? (elem-color parsed-elem)
+ (str (utils/rjust print-width (source-str parsed-elem))
+ " " (method-str parsed-elem))))
(.append on "\n")
(.flush on))))
@@ -91,16 +86,16 @@
(pst-cause-on on color? cause source-width)))
(defn- find-source-width
- "Returns the width of the longest source-string among all trace elems of the
+ "Returns the width of the longest source-string among all trace elems of the
excp and its causes."
[excp]
- (let [this-source-width (utils/fence
- (sort
- (map #(.length %)
- (map source-str (:trace-elems excp)))))]
- (if-let [cause (:cause excp)]
- (max this-source-width (find-source-width cause))
- this-source-width)))
+ (let [this-source-width (utils/fence
+ (sort
+ (map #(.length %)
+ (map source-str (:trace-elems excp)))))]
+ (if-let [cause (:cause excp)]
+ (max this-source-width (find-source-width cause))
+ this-source-width)))
(defn pst-on [on color? e]
"Prints to the given Writer on a pretty stack trace for the given exception e,
View
20 src/clj_stacktrace/utils.clj
@@ -5,10 +5,10 @@
representing a key and value in the new map."
[f coll]
(reduce
- (fn [memo elem]
- (let [[k v] (f elem)]
- (assoc memo k v)))
- {} coll))
+ (fn [memo elem]
+ (let [[k v] (f elem)]
+ (assoc memo k v)))
+ {} coll))
(defn re-gsub
"Simple version of re-gsub that only supports string replacements."
@@ -52,9 +52,9 @@
(defn quartile1
"Compute the first quartile for the given collection according to
Tukey (Hoaglin et al. 1983). coll must be sorted."
- ; Hoaglin, D.; Mosteller, F.; and Tukey, J. (Ed.).
- ; Understanding Robust and Exploratory Data Analysis.
- ; New York: Wiley, pp. 39, 54, 62, 223, 1983.
+ ;; Hoaglin, D.; Mosteller, F.; and Tukey, J. (Ed.).
+ ;; Understanding Robust and Exploratory Data Analysis.
+ ;; New York: Wiley, pp. 39, 54, 62, 223, 1983.
[coll]
(let [c (count coll)]
(nth coll (if (even? c)
@@ -64,9 +64,9 @@
(defn quartile3
"Compute the third quartile for the given collection according to
Tukey (Hoaglin et al. 1983). coll must be sorted."
- ; Hoaglin, D.; Mosteller, F.; and Tukey, J. (Ed.).
- ; Understanding Robust and Exploratory Data Analysis.
- ; New York: Wiley, pp. 39, 54, 62, 223, 1983.
+ ;; Hoaglin, D.; Mosteller, F.; and Tukey, J. (Ed.).
+ ;; Understanding Robust and Exploratory Data Analysis.
+ ;; New York: Wiley, pp. 39, 54, 62, 223, 1983.
[coll]
(let [c (count coll)]
(nth coll (if (even? c)
View
46 test/clj_stacktrace/core_test.clj
@@ -5,51 +5,65 @@
(def cases-data
[["foo.bar$biz__123" "invoke" "bar.clj" 456
- {:clojure true :ns "foo.bar" :fn "biz" :file "bar.clj" :line 456 :annon-fn false}]
+ {:clojure true :ns "foo.bar" :fn "biz"
+ :file "bar.clj" :line 456 :annon-fn false}]
["foo.bar$biz_bat__123" "invoke" "bar.clj" 456
- {:clojure true :ns "foo.bar" :fn "biz-bat" :file "bar.clj" :line 456 :annon-fn false}]
+ {:clojure true :ns "foo.bar" :fn "biz-bat"
+ :file "bar.clj" :line 456 :annon-fn false}]
["foo.bar$biz_bat_QMARK___448" "invoke" "bar.clj" 456
- {:clojure true :ns "foo.bar" :fn "biz-bat?" :file "bar.clj" :line 456 :annon-fn false}]
+ {:clojure true :ns "foo.bar" :fn "biz-bat?"
+ :file "bar.clj" :line 456 :annon-fn false}]
["foo.bar$biz_bat_QMARK___448$fn__456" "invoke" "bar.clj" 456
- {:clojure true :ns "foo.bar" :fn "biz-bat?" :file "bar.clj" :line 456 :annon-fn true}]
+ {:clojure true :ns "foo.bar" :fn "biz-bat?"
+ :file "bar.clj" :line 456 :annon-fn true}]
["foo.bar$repl$fn__5629.invoke" "invoke" "bar.clj" 456
- {:clojure true :ns "foo.bar" :fn "repl" :file "bar.clj" :line 456 :annon-fn true}]
+ {:clojure true :ns "foo.bar" :fn "repl"
+ :file "bar.clj" :line 456 :annon-fn true}]
["foo.bar$repl$read_eval_print__5624" "invoke" "bar.clj" 456
- {:clojure true :ns "foo.bar" :fn "repl" :file "bar.clj" :line 456 :annon-fn true}]
+ {:clojure true :ns "foo.bar" :fn "repl"
+ :file "bar.clj" :line 456 :annon-fn true}]
["foo.bar$biz__123$fn__456" "invoke" "bar.clj" 789
- {:clojure true :ns "foo.bar" :fn "biz" :file "bar.clj" :line 789 :annon-fn true}]
+ {:clojure true :ns "foo.bar" :fn "biz"
+ :file "bar.clj" :line 789 :annon-fn true}]
["foo.bar_bat$biz__123" "invoke" "bar.clj" 456
- {:clojure true :ns "foo.bar-bat" :fn "biz" :file "bar.clj" :line 456 :annon-fn false}]
+ {:clojure true :ns "foo.bar-bat" :fn "biz"
+ :file "bar.clj" :line 456 :annon-fn false}]
["user$eval__345" "invoke" nil -1
- {:clojure true :ns "user" :fn "eval" :file nil :line nil :annon-fn false}]
+ {:clojure true :ns "user" :fn "eval"
+ :file nil :line nil :annon-fn false}]
["clojure.lang.Var" "invoke" "Var.java" 123
- {:java true :class "clojure.lang.Var" :method "invoke" :file "Var.java" :line 123}]
+ {:java true :class "clojure.lang.Var" :method "invoke"
+ :file "Var.java" :line 123}]
["clojure.proxy.space.SomeClass" "someMethod" "SomeClass.java" 123
- {:java true :class "clojure.proxy.space.SomeClass" :method "someMethod" :file "SomeClass.java" :line 123}]
+ {:java true :class "clojure.proxy.space.SomeClass" :method "someMethod"
+ :file "SomeClass.java" :line 123}]
["some.space.SomeClass" "someMethod" "SomeClass.java" 123
- {:java true :class "some.space.SomeClass" :method "someMethod" :file "SomeClass.java" :line 123}]
+ {:java true :class "some.space.SomeClass" :method "someMethod"
+ :file "SomeClass.java" :line 123}]
["some.space.SomeClass$SomeInner" "someMethod" "SomeClass.java" 123
- {:java true :class "some.space.SomeClass$SomeInner" :method "someMethod" :file "SomeClass.java" :line 123}]
+ {:java true :class "some.space.SomeClass$SomeInner" :method "someMethod"
+ :file "SomeClass.java" :line 123}]
["some.space.SomeClass" "someMethod" nil -1
- {:java true :class "some.space.SomeClass" :method "someMethod" :file nil :line nil}]])
+ {:java true :class "some.space.SomeClass" :method "someMethod"
+ :file nil :line nil}]])
(def cases
(mash
- (fn [[c m f l p]] [(StackTraceElement. c m f l) p])
- cases-data))
+ (fn [[c m f l p]] [(StackTraceElement. c m f l) p])
+ cases-data))
(deftest test-parse-trace-elem
(doseq [[elem parsed] cases]
View
6 test/clj_stacktrace/repl_test.clj
@@ -8,9 +8,9 @@
that includes a caused-by cascade."
[binding-sym & body]
`(try (first (lazy-seq (cons (/) nil)))
- (catch Exception e#
- (let [~binding-sym e#]
- ~@body))))
+ (catch Exception e#
+ (let [~binding-sym e#]
+ ~@body))))
(deftest test-pst
(with-cascading-exception e
Please sign in to comment.
Something went wrong with that request. Please try again.