Skip to content

Commit 26f72e5

Browse files
Bump Orchard to 0.31.1
1 parent 49145e6 commit 26f72e5

File tree

8 files changed

+23
-44
lines changed

8 files changed

+23
-44
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## master (unreleased)
44

5-
* Bump `orchard` to [0.31.0](https://github.com/clojure-emacs/orchard/blob/master/CHANGELOG.md#0310-2025-03-14).
5+
* Bump `orchard` to [0.31.1](https://github.com/clojure-emacs/orchard/blob/master/CHANGELOG.md#0311-2025-03-19).
66
- Info: recognize printed Java classes/methods and munged Clojure functions in stacktrace outputs.
77
- Add dedicated renderers for exceptions in inspector and debugger.
88
* [#919](https://github.com/clojure-emacs/cider-nrepl/pull/919): Move exception analysis to Orchard.

project.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
:url "http://www.eclipse.org/legal/epl-v10.html"}
2222
:scm {:name "git" :url "https://github.com/clojure-emacs/cider-nrepl"}
2323
:dependencies [[nrepl/nrepl "1.3.1" :exclusions [org.clojure/clojure]]
24-
[cider/orchard "0.31.0" :exclusions [org.clojure/clojure]]
24+
[cider/orchard "0.31.1" :exclusions [org.clojure/clojure]]
2525
^:inline-dep [thunknyc/profile "0.5.2"]
2626
^:inline-dep [mvxcvi/puget "1.3.4" :exclusions [org.clojure/clojure]]
2727
^:inline-dep [fipp ~fipp-version] ; can be removed in unresolved-tree mode

src/cider/nrepl/middleware/debug.clj

+3-3
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ this map (identified by a key), and will `dissoc` it afterwards."}
216216
(when-not (instance? ThreadDeath root-ex#)
217217
(debugger-send
218218
{:status :eval-error
219-
:causes [(let [causes# (stacktrace/analyze e# (::print/print-fn *msg*))]
219+
:causes [(let [causes# (stacktrace/analyze e#)]
220220
(when (coll? causes#) (last causes#)))]})))
221221
error#))]
222222
(if (= error# ~sym)
@@ -288,11 +288,11 @@ this map (identified by a key), and will `dissoc` it afterwards."}
288288
(debugger-send
289289
{:status :stack
290290
:causes (if (instance? Throwable value)
291-
(stacktrace/analyze value (::print/print-fn *msg*))
291+
(stacktrace/analyze value)
292292
[{:class "StackTrace"
293293
:message "Harmless user-requested stacktrace"
294294
:stacktrace (-> (Exception. "Dummy")
295-
(stacktrace/analyze (::print/print-fn *msg*))
295+
stacktrace/analyze
296296
last :stacktrace)}])}))
297297

298298
(def debug-commands

src/cider/nrepl/middleware/reload.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
:else (reload opts))))
3939

4040
(defn- reload-reply
41-
[{:keys [::print/print-fn transport session id] :as msg}]
41+
[{:keys [session id] :as msg}]
4242
(let [{:keys [exec]} (meta session)]
4343
(exec id
4444
(fn []
@@ -51,7 +51,7 @@
5151
(respond-to msg {:status :ok}))
5252
(catch Throwable error
5353
(respond-to msg {:status :error
54-
:error (stacktrace/analyze error print-fn)})
54+
:error (stacktrace/analyze error)})
5555
(binding [*msg* msg
5656
*err* (print/replying-PrintWriter :err msg {})]
5757
(repl-caught error)))))

src/cider/nrepl/middleware/stacktrace.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
(defn- analyze-last-stacktrace
2323
"Analyze the last exception."
24-
[{:keys [session ::print/print-fn] :as msg}]
24+
[{:keys [session] :as msg}]
2525
(let [last-exception (@session #'*e)]
2626
(swap! session assoc #'*last-exception* last-exception) ;; note that *e can change later, so this entry isn't redundant
27-
(send-analysis msg (stacktrace/analyze last-exception print-fn))))
27+
(send-analysis msg (stacktrace/analyze last-exception))))
2828

2929
(defn- handle-analyze-last-stacktrace-op
3030
"Handle the analyze last stacktrace op."

src/cider/nrepl/middleware/test.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -474,14 +474,14 @@
474474
(respond-to msg :status :done)))))
475475

476476
(defn handle-stacktrace-op
477-
[{:keys [ns var index session id ::print/print-fn] :as msg}]
477+
[{:keys [ns var index session id] :as msg}]
478478
(let [{:keys [exec]} (meta session)]
479479
(exec id
480480
(fn []
481481
(with-bindings (assoc @session #'ie/*msg* msg)
482482
(let [[ns var] (map misc/as-sym [ns var])]
483483
(if-let [e (get-in @results [ns var index :error])]
484-
(doseq [cause (stacktrace/analyze e print-fn)]
484+
(doseq [cause (stacktrace/analyze e)]
485485
(respond-to msg cause))
486486
(respond-to msg :status :no-error)))))
487487
(fn []

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

+10-28
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,35 @@
33
errors/exceptions that might arise from doing so."
44
(:refer-clojure :exclude [error-handler])
55
(:require
6+
[clojure.main]
67
[clojure.set :as set]
8+
[clojure.stacktrace]
79
[clojure.walk :as walk]
810
[nrepl.middleware.caught :as caught]
911
[nrepl.middleware.print :as print]
1012
[nrepl.misc :refer [response-for]]
11-
[nrepl.transport :as transport])
13+
[nrepl.transport :as transport]
14+
[orchard.stacktrace :as stacktrace])
1215
(:import
1316
java.io.InputStream
1417
clojure.lang.RT
1518
(nrepl.transport Transport)))
1619

17-
(def ^:private print-cause-trace
18-
(delay
19-
(requiring-resolve 'clojure.stacktrace/print-cause-trace)))
20-
21-
(def ^:private analyze-causes
22-
(delay
23-
(requiring-resolve 'orchard.stacktrace/analyze)))
24-
2520
;;; UTILITY FUNCTIONS
2621

27-
(defn error-summary
28-
"Takes a `java.lang.Exception` as `ex` and returns a map summarizing
29-
the exception. If present, the varargs are converted to a set and
30-
used as the value for the :status key."
31-
[ex & statuses]
32-
(merge {:ex (str (class ex))
33-
:err (with-out-str (@print-cause-trace ex))
34-
:root-ex (-> (#'clojure.main/root-cause ex) class str)}
35-
(when statuses {:status (set statuses)})))
36-
37-
(defn pp-stacktrace
38-
"Takes a `java.lang.Exception` as `ex` and a pretty-print function
39-
as `print-fn`, then returns a pretty-printed version of the
40-
exception that can be rendered by CIDER's stacktrace viewer."
41-
[ex print-fn]
42-
{:pp-stacktrace (@analyze-causes ex print-fn)})
43-
4422
(defn base-error-response
4523
"Takes a CIDER-nREPL message as `msg`, an Exception `ex`, and a
4624
non-collection vararg of `statuses`. This will return the standard
4725
response for CIDER-nREPL sync-op errors that can be rendered by
4826
CIDER's stacktrace viewer. N.B., statuses such as `:done` and
4927
`:<op-name>-error` are NOT automatically added"
5028
[msg ex & statuses]
51-
(response-for msg (merge (apply error-summary ex statuses)
52-
(pp-stacktrace ex (::print/print-fn msg)))))
29+
(response-for
30+
msg (merge {:ex (str (class ex))
31+
:err (with-out-str (clojure.stacktrace/print-cause-trace ex))
32+
:root-ex (str (class (clojure.main/root-cause ex)))
33+
:pp-stacktrace (stacktrace/analyze ex)}
34+
(when statuses {:status (set statuses)}))))
5335

5436
(defn- normalize-status
5537
"Accepts various representations of an nREPL reply message's status

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
[orchard.misc :as misc]
1010
[orchard.stacktrace :as stacktrace]))
1111

12-
(defn error-reply
13-
[{:keys [error error-ns]}
14-
{:keys [::print/print-fn] :as msg}]
15-
12+
(defn error-reply [{:keys [error error-ns]} msg]
1613
(respond-to msg (cond-> {:status :error}
17-
error (assoc :error (stacktrace/analyze error print-fn))
14+
error (assoc :error (stacktrace/analyze error))
1815
error-ns (assoc :error-ns error-ns)))
1916

2017
(binding [*msg* msg

0 commit comments

Comments
 (0)