Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6bee102

Browse files
committedJun 14, 2023
Debug stacktrace of value if it's an exception
1 parent a53ab41 commit 6bee102

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed
 

‎src/cider/nrepl/middleware/debug.clj

+11-8
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,18 @@ this map (identified by a key), and will `dissoc` it afterwards."}
284284
:rendered pr-str)))
285285

286286
(defn- debug-stacktrace
287-
"Create a dummy exception, send its stack."
288-
[]
287+
"Send the stacktrace of `value` if it is an exception.
288+
Otherwise, create a dummy exception to view the call stack at the current location."
289+
[value]
289290
(debugger-send
290291
{:status :stack
291-
:causes [{:class "StackTrace"
292-
:message "Harmless user-requested stacktrace"
293-
:stacktrace (-> (Exception. "Dummy")
294-
(stacktrace.analyzer/analyze (::print/print-fn *msg*))
295-
last :stacktrace)}]}))
292+
:causes (if (instance? Throwable value)
293+
(stacktrace.analyzer/analyze value (::print/print-fn *msg*))
294+
[{:class "StackTrace"
295+
:message "Harmless user-requested stacktrace"
296+
:stacktrace (-> (Exception. "Dummy")
297+
(stacktrace.analyzer/analyze (::print/print-fn *msg*))
298+
last :stacktrace)}])}))
296299

297300
(def debug-commands
298301
"An unsorted set of commands supported by the debugger."
@@ -365,7 +368,7 @@ this map (identified by a key), and will `dissoc` it afterwards."}
365368
value)
366369
:here (do (skip-breaks! :before coord (:code dbg-state) force?)
367370
value)
368-
:stacktrace (do (debug-stacktrace)
371+
:stacktrace (do (debug-stacktrace value)
369372
(recur value dbg-state))
370373
:trace (do (skip-breaks! :trace)
371374
value)

0 commit comments

Comments
 (0)
Please sign in to comment.