Skip to content

Commit c60d2db

Browse files
authored
CIDER macroexpand: handle errors more gracefully (#3557)
Closes #3554
1 parent af264ef commit c60d2db

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Improves performance for completions- and info-related functionality.
99
- Updates [Orchard](https://github.com/clojure-emacs/orchard/blob/v0.18.0/CHANGELOG.md#0180-2023-10-30)
1010
- Improves various Inspector presentational aspects.
11+
- [#3554](https://github.com/clojure-emacs/cider/issues/3554): CIDER macroexpand: handle errors more gracefully.
1112

1213
### Bugs fixed
1314

cider-macroexpansion.el

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,19 @@ Possible values are:
6363
The default for DISPLAY-NAMESPACES is taken from
6464
`cider-macroexpansion-display-namespaces'."
6565
(cider-ensure-op-supported "macroexpand")
66-
(thread-first `("op" "macroexpand"
67-
"expander" ,expander
68-
"code" ,expr
69-
"ns" ,(cider-current-ns)
70-
"display-namespaces" ,(or display-namespaces
71-
(symbol-name cider-macroexpansion-display-namespaces)))
72-
(nconc (when cider-macroexpansion-print-metadata
73-
'("print-meta" "true")))
74-
(cider-nrepl-send-sync-request)
75-
(nrepl-dict-get "expansion")))
66+
(let ((result (thread-first `("op" "macroexpand"
67+
"expander" ,expander
68+
"code" ,expr
69+
"ns" ,(cider-current-ns)
70+
"display-namespaces" ,(or display-namespaces
71+
(symbol-name cider-macroexpansion-display-namespaces)))
72+
(nconc (when cider-macroexpansion-print-metadata
73+
'("print-meta" "true")))
74+
(cider-nrepl-send-sync-request))))
75+
(nrepl-dbind-response result (expansion status)
76+
(if (member "macroexpand-error" status)
77+
(user-error "Macroexpansion failed. Check *cider-error* for more details")
78+
expansion))))
7679

7780
(defun cider-macroexpand-undo (&optional arg)
7881
"Undo the last macroexpansion, using `undo-only'.

cider-stacktrace.el

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,9 @@ others."
643643
"Emit toggle buttons for each of the ERROR-TYPES leading this stacktrace BUFFER."
644644
(with-current-buffer buffer
645645
(when error-types
646-
(insert " This is an unexpected CIDER middleware error.\n Please submit a bug report via `")
646+
(insert " This is a CIDER middleware error.
647+
It may be a due to a bug, or perhaps simply to bad user input.
648+
If you believe it's a bug, please submit an issue report via `")
647649
(insert-text-button "M-x cider-report-bug"
648650
'follow-link t
649651
'action (lambda (_button) (cider-report-bug))

0 commit comments

Comments
 (0)