Skip to content

Commit fa43d28

Browse files
malltbbatsov
authored andcommitted
[Fix #225] Add :root-ex to error summary (#563)
1 parent 602efe9 commit fa43d28

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
### Changes
1212

1313
* [#550](https://github.com/clojure-emacs/cider-nrepl/pull/550): Always return test documentation messages as strings.
14+
* [#563](https://github.com/clojure-emacs/cider-nrepl/pull/563): Add :root-ex key to error summary that contains the classname of the root cause.
1415

1516
## 0.18.0 (2018-08-06)
1617

src/cider/nrepl/middleware/util/error_handling.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
used as the value for the :status key."
3838
[ex & statuses]
3939
(merge {:ex (str (class ex))
40-
:err (with-out-str (@print-cause-trace ex))}
40+
:err (with-out-str (@print-cause-trace ex))
41+
:root-ex (-> (#'clojure.main/root-cause ex) class str)}
4142
(when statuses {:status (set statuses)})))
4243

4344
(defn pp-stacktrace

test/clj/cider/nrepl/middleware/util/error_handling_test.clj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,11 @@
5858
(is (deep-bencodable? [:a :vector 1 {:a :map} 2 '(:a {:bad-map *ns*} :list) 3])
5959
"Should pass since *ns* is inside a quoted list and doesn't get evaluated")
6060
(is (thrown? IllegalArgumentException (deep-bencodable? [:a :vector 1 {:a :map} 2 [:sub :vec :bad *ns*] '(:a :list) 3]))))))
61+
62+
(deftest error-handler-root-ex
63+
(let [e (Exception. "testing" (Throwable. "root-cause"))
64+
e2 (Exception. "testing2")]
65+
(is (= "class java.lang.Throwable"
66+
(:root-ex (err/error-handler :done {:id 1} e))))
67+
(is (= "class java.lang.Exception"
68+
(:root-ex (err/error-handler :done {:id 2} e2))))))

0 commit comments

Comments
 (0)