Skip to content

Commit 2865e66

Browse files
Remove features that relied on printed exception parsing
1 parent ee6ad0e commit 2865e66

File tree

6 files changed

+26
-236
lines changed

6 files changed

+26
-236
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
### Changes
66

77
- [#3782](https://github.com/clojure-emacs/cider/issues/3782): **(Breaking)** Drop official support for Emacs 26.
8+
- [#3793](https://github.com/clojure-emacs/cider/issues/3793): **(Breaking)** Remove features that relied on printed exception parsing:
9+
- `cider-stacktrace-analyze-string` and `cider-stacktrace-analyze-at-point` functions.
10+
- Automatic stacktrace parsing in log viewer.
811
- Bump the injected `cider-nrepl` to [0.53.1](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md#0531-2025-03-26).
912
- Info: recognize printed Java classes/methods and munged Clojure functions in stacktrace outputs.
1013
- Inspector: add dedicated view for Exceptions.

cider-log.el

+6-42
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,6 @@ It will not be used if the package hasn't been installed."
215215
"filters" ,(cider-log-consumer-filters consumer))
216216
(cider-nrepl-send-request callback)))
217217

218-
(defun cider-request:log-analyze-stacktrace (framework appender event &optional callback)
219-
"Analyze the EVENT stacktrace of the APPENDER of FRAMEWORK and call CALLBACK."
220-
(cider-ensure-op-supported "cider/log-analyze-stacktrace")
221-
(thread-first `("op" "cider/log-analyze-stacktrace"
222-
"framework" ,(cider-log-framework-id framework)
223-
"appender" ,(cider-log-appender-id appender)
224-
"event" ,(cider-log-event-id event))
225-
(cider-nrepl-send-request callback)))
226-
227218
(defun cider-sync-request:log-update-consumer (framework appender consumer)
228219
"Add CONSUMER to the APPENDER of FRAMEWORK and call CALLBACK on log events."
229220
(cider-ensure-op-supported "cider/log-update-consumer")
@@ -690,24 +681,6 @@ The KEYS are used to lookup the values and are joined by SEPARATOR."
690681
(seq-doseq (window windows)
691682
(set-window-point window (point-max))))))
692683

693-
(defun cider-log-event--show-stacktrace (framework appender event)
694-
"Show the stacktrace of the log EVENT of FRAMEWORK and APPENDER."
695-
(when (and framework appender event (cider-log-event-exception event))
696-
(let ((auto-select-buffer cider-auto-select-error-buffer)
697-
(causes nil))
698-
(cider-request:log-analyze-stacktrace
699-
framework appender event
700-
(lambda (response)
701-
(nrepl-dbind-response response (class status)
702-
(cond (class (setq causes (cons response causes)))
703-
(status (when causes
704-
(cider-stacktrace-render
705-
(cider-popup-buffer cider-error-buffer
706-
auto-select-buffer
707-
#'cider-stacktrace-mode
708-
'ancillary)
709-
(reverse causes)))))))))))
710-
711684
(defun cider-log-event-next-line (&optional n)
712685
"Move N lines forward."
713686
(interactive "p")
@@ -719,8 +692,6 @@ The KEYS are used to lookup the values and are joined by SEPARATOR."
719692
(event (cider-log-event-at-point)))
720693
(let ((cider-auto-select-error-buffer nil))
721694
(save-window-excursion
722-
(when (get-buffer-window cider-error-buffer)
723-
(cider-log-event--show-stacktrace framework appender event))
724695
(when (get-buffer-window cider-inspector-buffer)
725696
(cider-log-event--inspect framework appender event))
726697
(when (get-buffer-window cider-log-event-buffer)
@@ -856,7 +827,6 @@ The KEYS are used to lookup the values and are joined by SEPARATOR."
856827
(define-key map (kbd "C-c M-l f") #'cider-log-framework)
857828
(define-key map (kbd "C-c M-l i") #'cider-log-info)
858829
(define-key map (kbd "C-c M-l l") #'cider-log)
859-
(define-key map (kbd "E") 'cider-log-show-stacktrace)
860830
(define-key map (kbd "F") 'cider-log-print-event)
861831
(define-key map (kbd "I") 'cider-log-inspect-event)
862832
(define-key map (kbd "RET") 'cider-log-inspect-event)
@@ -1173,16 +1143,12 @@ the CIDER Inspector and the CIDER stacktrace mode.
11731143
(cider-log-appender-display-name appender)))
11741144

11751145
;; Event actions
1176-
1177-
(transient-define-suffix cider-log-show-stacktrace (framework appender event)
1178-
"Show the stacktrace of the log EVENT of FRAMEWORK and APPENDER."
1179-
:description "Show log event stacktrace"
1180-
:if #'cider-log-event-at-point
1181-
:inapt-if-not (lambda ()
1182-
(when-let (event (cider-log-event-at-point))
1183-
(cider-log-event-exception event)))
1184-
(interactive (list (cider-log--framework) (cider-log--appender) (cider-log-event-at-point)))
1185-
(cider-log-event--show-stacktrace framework appender event))
1146+
(defun cider-log-show-stacktrace (&rest _)
1147+
"Removed."
1148+
(interactive)
1149+
(message "This function has been removed.
1150+
You can jump to functions and methods directly from the printed stacktrace now."))
1151+
(make-obsolete 'cider-log-show-stacktrace nil "1.18")
11861152

11871153
(transient-define-suffix cider-log-print-event (framework appender event)
11881154
"Format the log EVENT of FRAMEWORK and APPENDER."
@@ -1439,7 +1405,6 @@ the CIDER Inspector and the CIDER stacktrace mode.
14391405
(cider-log--threads-option)]
14401406
["Actions"
14411407
("c" cider-log-clear-event-buffer)
1442-
("e" cider-log-show-stacktrace)
14431408
("i" cider-log-inspect-event)
14441409
("p" cider-log-print-event)
14451410
("s" cider-log--do-search-events)]
@@ -1497,7 +1462,6 @@ based on `transient-mode'."
14971462
["Event Actions"
14981463
("eb" cider-log-switch-to-buffer)
14991464
("ec" cider-log-clear-event-buffer)
1500-
("ee" cider-log-show-stacktrace)
15011465
("ei" cider-log-inspect-event)
15021466
("ep" cider-log-print-event)
15031467
("es" "Search log events" cider-log-event-search

cider-stacktrace.el

+11-39
Original file line numberDiff line numberDiff line change
@@ -930,47 +930,19 @@ through the `cider-stacktrace-suppressed-errors' variable."
930930
(cider-stacktrace-initialize causes)
931931
(font-lock-refresh-defaults)))
932932

933-
(defun cider-stacktrace--analyze-stacktrace-op (stacktrace)
934-
"Return the Cider NREPL op to analyze STACKTRACE."
935-
(list "op" "analyze-stacktrace" "stacktrace" stacktrace))
936-
937-
(defun cider-stacktrace--analyze-render (causes)
938-
"Render the CAUSES of the stacktrace analysis result."
939-
(let ((buffer (get-buffer-create cider-error-buffer)))
940-
(with-current-buffer buffer
941-
(cider-stacktrace-mode)
942-
(cider-stacktrace-render buffer (reverse causes))
943-
(display-buffer buffer cider-jump-to-pop-to-buffer-actions))))
944-
945-
(defun cider-stacktrace-analyze-string (stacktrace)
946-
"Analyze the STACKTRACE string and show the result."
947-
(when (stringp stacktrace)
948-
(set-text-properties 0 (length stacktrace) nil stacktrace))
949-
(let (causes)
950-
(cider-nrepl-send-request
951-
`("op" "analyze-stacktrace"
952-
"stacktrace" ,stacktrace
953-
,@(cider--nrepl-print-request-plist fill-column))
954-
(lambda (response)
955-
(setq causes (nrepl-dbind-response response (class status)
956-
(cond (class (cons response causes))
957-
((and (member "done" status) causes)
958-
(cider-stacktrace--analyze-render causes)))))))))
959-
960933
(defun cider-stacktrace-analyze-at-point ()
961-
"Analyze the stacktrace at point."
934+
"Removed."
935+
(interactive)
936+
(message "This function has been removed.
937+
You can jump to functions and methods directly from the printed stacktrace now."))
938+
(make-obsolete 'cider-stacktrace-analyze-at-point nil "1.18")
939+
940+
(defun cider-stacktrace-analyze-in-region (&rest _)
941+
"Removed."
962942
(interactive)
963-
(cond ((thing-at-point 'sentence)
964-
(cider-stacktrace-analyze-string (thing-at-point 'sentence)))
965-
((thing-at-point 'paragraph)
966-
(cider-stacktrace-analyze-string (thing-at-point 'paragraph)))
967-
(t (cider-stacktrace-analyze-in-region (region-beginning) (region-end)))))
968-
969-
(defun cider-stacktrace-analyze-in-region (beg end)
970-
"Analyze the stacktrace in the region between BEG and END."
971-
(interactive (list (region-beginning) (region-end)))
972-
(let ((stacktrace (buffer-substring beg end)))
973-
(cider-stacktrace-analyze-string stacktrace)))
943+
(message "This function has been removed.
944+
You can jump to functions and methods directly from the printed stacktrace now."))
945+
(make-obsolete 'cider-stacktrace-analyze-in-region nil "1.18")
974946

975947
(provide 'cider-stacktrace)
976948

doc/modules/ROOT/pages/debugging/logging.adoc

+6-15
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,22 @@
44
CIDER Log Mode allows you to capture, debug, inspect and view log
55
events emitted by Java logging frameworks. The captured log events can
66
be searched, streamed to the client, pretty-printed, and are integrated
7-
with the CIDER link:inspector.html[Inspector] and
8-
link:../usage/dealing_with_errors.html[Stacktrace Mode]. Here is a
7+
with the CIDER link:inspector.html[Inspector]. Here is a
98
screenshot of CIDER Log Mode in action.
109

1110
image::cider-log.png[CIDER Log]
1211

13-
NOTE: The screenshot displays the list of log events in the
14-
`+*cider-log*+` buffer on the left. To the right, a log event is
15-
visible in the `+*cider-inspect*+` buffer, where the exception of the
16-
event is also displayed in the CIDER Stacktrace Mode. From the
17-
Stacktrace Mode buffer you can jump to the source of each frame. At
18-
the bottom the CIDER log menu is shown from which you can perform
19-
logging related actions.
12+
NOTE: The screenshot displays the list of log events in the `+*cider-log*+`
13+
buffer on the left. To the right, a log event is visible in the
14+
`+*cider-inspect*+` buffer. At the bottom the CIDER log menu is shown from which
15+
you can perform logging related actions.
2016

2117
== Features
2218

2319
- Browse Javadocs and website of the given log framework.
2420
- Search log events and show them in buffers.
2521
- link:../usage/pretty_printing.html[Pretty-print] log events.
2622
- Show log events in the CIDER link:inspector.html[Inspector].
27-
- Show log event exceptions in the CIDER link:../usage/dealing_with_errors.html[Stacktrace Mode].
2823
- Integration with https://github.com/doublep/logview[logview].
2924

3025
== Dependencies
@@ -278,7 +273,7 @@ The following keybindings can be used to interact with log consumers.
278273
== Log Event
279274

280275
Log events can be searched, streamed to a client or viewed in CIDER's
281-
Inspector and Stacktrace Mode. When searching log events the user can
276+
Inspector Mode. When searching log events the user can
282277
specify a set of filters. Events that match the filters are shown in
283278
the `+*cider-log*+` buffer. Additionally a log consumer will be
284279
attached to the appender to receive log events matching the search
@@ -301,10 +296,6 @@ The following keybindings can be used to interact with log events.
301296
| kbd:[C-c M-l e c]
302297
| Clear all events from the log event buffer.
303298

304-
| `cider-log-show-stacktrace`
305-
| kbd:[C-c M-l e e]
306-
| Show the stacktrace of the log event at point in the CIDER Stacktrace Mode.
307-
308299
| `cider-log-inspect-event`
309300
| kbd:[C-c M-l e i]
310301
| Show the log event in the CIDER Inspector.

doc/modules/ROOT/pages/usage/dealing_with_errors.adoc

-86
Original file line numberDiff line numberDiff line change
@@ -210,92 +210,6 @@ for instance:
210210
(setq cider-stacktrace-fill-column 80)
211211
----
212212

213-
=== Inspecting printed stacktraces
214-
215-
Some of the errors you encounter as a Clojurists aren't necessarily
216-
evaluation errors that happened in your REPL. Many times, you see
217-
errors printed in a textual representation in other buffers as well,
218-
like log files or the REPL for example. Cider can parse and analyze
219-
some of those printed errors as well and show them in
220-
`cider-stacktrace-mode` with the following commands:
221-
222-
* The `cider-stacktrace-analyze-at-point` command uses the `thingatpt`
223-
library to extract the current stacktrace at point. It sends the
224-
extracted stacktrace to the middleware in order to parse and analyze
225-
it, and then shows the result in Cider's `cider-stacktrace-mode`.
226-
227-
* The `cider-stacktrace-analyze-in-region` command does the same as
228-
`cider-stacktrace-analyze-at-point`, but uses the current region to
229-
extract the stacktrace.
230-
231-
==== Examples
232-
233-
Here is an example of a stacktrace printed with the Java
234-
`printStackTrace` method:
235-
236-
[source,text]
237-
----
238-
clojure.lang.ExceptionInfo: BOOM-1 {:boom "1"}
239-
at java.base/java.lang.Thread.run(Thread.java:829)
240-
----
241-
242-
To open this stacktrace in the Cider stacktrace inspector, move point
243-
somewhere over the exception and run `M-x
244-
cider-stacktrace-analyze-at-point`.
245-
246-
This also works to some extent for exceptions that are buried inside a
247-
string like the following exception:
248-
249-
[source,text]
250-
----
251-
"clojure.lang.ExceptionInfo: BOOM-1 {:boom \"1\"}\n at java.base/java.lang.Thread.run(Thread.java:829)"
252-
----
253-
254-
Those exceptions are often hard to read. The Cider stacktrace
255-
inspector can help you navigating exceptions even in those cases.
256-
257-
==== Supported formats
258-
259-
Cider recognizes stacktraces printed in the following formats:
260-
261-
- `Aviso` - Exceptions printed with the
262-
https://ioavisopretty.readthedocs.io/en/latest/exceptions.html[write-exception]
263-
function of the https://github.com/AvisoNovate/pretty[Aviso]
264-
library.
265-
266-
- `clojure.repl` - Exceptions printed with the
267-
https://clojure.github.io/clojure/branch-master/clojure.repl-api.html#clojure.repl/pst[clojure.repl/pst]
268-
function.
269-
270-
- `clojure.stacktrace` - Exceptions printed with the
271-
https://clojure.github.io/clojure/branch-master/clojure.stacktrace-api.html#clojure.stacktrace/print-cause-trace[clojure.stacktrace/print-cause-trace]
272-
function.
273-
274-
- `Java` - Exceptions printed with the
275-
https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#printStackTrace--[Throwable/printStackTrace]
276-
method.
277-
278-
- `Tagged Literal` - Exceptions printed with the
279-
https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/pr[clojure.core/pr]
280-
function.
281-
282-
==== Limitations
283-
284-
- Cider only recognizes stacktraces that have been printed in one of
285-
the supported formats.
286-
287-
- Stacktraces are analyzed with the classpath of the Cider session the
288-
buffer is associated with. If the stacktrace contains references to
289-
classes not on this classpath, some information might be missing
290-
from the analysis.
291-
292-
- The `cider-stacktrace-analyze-at-point` function might not detect
293-
the stacktrace at point in every situation. The thing at point might
294-
be different depending on which major mode is active in a
295-
buffer. When `cider-stacktrace-analyze-at-point` fails to detect the
296-
stacktrace, `cider-stacktrace-analyze-in-region` can be used to
297-
select the stacktrace manually.
298-
299213
== Inspector integration
300214

301215
Within `*cider-error*`, when clicking directly a top-level exception (any of them in the cause chain),

test/cider-stacktrace-tests.el

-54
Original file line numberDiff line numberDiff line change
@@ -257,57 +257,3 @@
257257
:to-be-truthy)
258258
(expect (or both shown1 shown2)
259259
:to-be nil))))
260-
261-
(defun cider-stacktrace-tests--analyze-at-point (stacktrace pos)
262-
"Test `cider-stacktrace-analyze-at-point' with STACKTRACE at POS."
263-
(with-temp-buffer
264-
(erase-buffer)
265-
(insert stacktrace)
266-
(goto-char pos)
267-
(cider-stacktrace-analyze-at-point)))
268-
269-
(describe "cider-stacktrace-analyze-at-point"
270-
:var (cider-stacktrace-analyze-string)
271-
(before-each (spy-on 'cider-stacktrace-analyze-string))
272-
273-
(it "should analyze the Aviso stacktrace with point at beginning"
274-
(cider-stacktrace-tests--analyze-at-point cider-stacktrace-tests-boom-aviso 0)
275-
(expect 'cider-stacktrace-analyze-string :to-have-been-called-with cider-stacktrace-tests-boom-aviso))
276-
277-
(it "should analyze the Clojure stacktrace with point at beginning"
278-
(cider-stacktrace-tests--analyze-at-point cider-stacktrace-tests-boom-clojure 0)
279-
(expect 'cider-stacktrace-analyze-string :to-have-been-called-with cider-stacktrace-tests-boom-clojure))
280-
281-
(it "should analyze the Java stacktrace with point at beginning"
282-
(cider-stacktrace-tests--analyze-at-point cider-stacktrace-tests-boom-java 0)
283-
(expect 'cider-stacktrace-analyze-string :to-have-been-called-with cider-stacktrace-tests-boom-java))
284-
285-
(it "should analyze the Clojure stacktrace with point inside"
286-
(cider-stacktrace-tests--analyze-at-point cider-stacktrace-tests-boom-clojure 10)
287-
(expect 'cider-stacktrace-analyze-string :to-have-been-called-with cider-stacktrace-tests-boom-clojure))
288-
289-
(it "should analyze the Java stacktrace with point inside"
290-
(cider-stacktrace-tests--analyze-at-point cider-stacktrace-tests-boom-java 10)
291-
(expect 'cider-stacktrace-analyze-string :to-have-been-called-with cider-stacktrace-tests-boom-java)))
292-
293-
(defun cider-stacktrace-tests--analyze-in-region (stacktrace)
294-
"Test `cider-stacktrace-analyze-in-region' with STACKTRACE."
295-
(with-temp-buffer
296-
(insert stacktrace)
297-
(cider-stacktrace-analyze-in-region (point-min) (point-max))))
298-
299-
(describe "cider-stacktrace-analyze-in-region"
300-
:var (cider-stacktrace-analyze-string)
301-
(before-each (spy-on 'cider-stacktrace-analyze-string))
302-
303-
(it "should analyze the Aviso stacktrace in region"
304-
(cider-stacktrace-tests--analyze-in-region cider-stacktrace-tests-boom-aviso)
305-
(expect 'cider-stacktrace-analyze-string :to-have-been-called-with cider-stacktrace-tests-boom-aviso))
306-
307-
(it "should analyze the Clojure stacktrace in region"
308-
(cider-stacktrace-tests--analyze-in-region cider-stacktrace-tests-boom-clojure)
309-
(expect 'cider-stacktrace-analyze-string :to-have-been-called-with cider-stacktrace-tests-boom-clojure))
310-
311-
(it "should analyze the Java stacktrace in region"
312-
(cider-stacktrace-tests--analyze-in-region cider-stacktrace-tests-boom-java)
313-
(expect 'cider-stacktrace-analyze-string :to-have-been-called-with cider-stacktrace-tests-boom-java)))

0 commit comments

Comments
 (0)