@@ -70,7 +70,14 @@ not to be automatically shown.
70
70
71
71
Irrespective of the value of this variable, the `cider-error-buffer' is
72
72
always generated in the background. Use `cider-selector' to
73
- navigate to this buffer."
73
+ navigate to this buffer.
74
+
75
+ Please note, if the error phase belongs to
76
+ one of the `cider-ignored-error-phases' , then no stacktrace showing will happen.
77
+ That defcustom takes precedence over this one.
78
+
79
+ See its doc for understanding its rationale. You can also customize it to nil
80
+ in order to void its effect."
74
81
:type '(choice (const :tag " always" t )
75
82
(const except-in-repl)
76
83
(const only-in-repl)
@@ -478,32 +485,63 @@ op/situation that originated this error."
478
485
(let ((error-buffer (cider-new-error-buffer #'cider-stacktrace-mode error-types)))
479
486
(cider-stacktrace-render error-buffer (reverse causes) error-types))))
480
487
481
- (defun cider--handle-stacktrace-response (response causes )
482
- " Handle stacktrace op RESPONSE, aggregating the result into CAUSES.
488
+ (defcustom cider-ignored-error-phases '(" read-source"
489
+ " macro-syntax-check"
490
+ " macroexpansion"
491
+ " compile-syntax-check"
492
+ " compilation"
493
+ ; ; "execution" is certainly not to be included here.
494
+ ; ; "read-eval-result" and "print-eval-result" are not to be included here,
495
+ ; ; because they mean that the code has been successfully executed.
496
+ )
497
+ " Clojure error phases which will not trigger a UI to become visible.
498
+
499
+ Those UIs include, at the moment:
500
+
501
+ * showing stacktraces in `*cider-error*'
502
+ * as otherwise controlled by the `cider-show-error-buffer' defcustom
503
+
504
+ `cider-ignored-error-phases' takes precedence
505
+ over the other mentioned defcustoms.
506
+ If you wish phases to be ignored, set this variable to nil instead.
507
+
508
+ You can learn more about Clojure's error phases at:
509
+ https://clojure.org/reference/repl_and_main#_at_repl"
510
+ :type 'list
511
+ :group 'cider
512
+ :package-version '(cider . " 0.18.0" ))
513
+
514
+ (defun cider--handle-stacktrace-response (response causes ex-phase )
515
+ " Handle stacktrace RESPONSE, aggregate the result into CAUSES, honor EX-PHASE.
483
516
If RESPONSE contains a cause, cons it onto CAUSES and return that. If
484
517
RESPONSE is the final message (i.e. it contains a status), render CAUSES
485
518
into a new error buffer."
486
519
(nrepl-dbind-response response (class msg status type)
487
520
(cond ((and (member " notification" status) causes)
488
521
(nrepl-notify msg type))
489
522
(class (cons response causes))
490
- (status (cider--render-stacktrace-causes causes)))))
523
+ (status
524
+ (unless (member ex-phase cider-ignored-error-phases)
525
+ (cider--render-stacktrace-causes causes))))))
491
526
492
527
(defun cider-default-err-op-handler ()
493
528
" Display the last exception, with middleware support."
494
529
; ; Causes are returned as a series of messages, which we aggregate in `causes'
495
- (let (causes)
530
+ (let (causes ex-phase )
496
531
(cider-nrepl-send-request
497
532
(thread-last
498
533
(map-merge 'list
499
534
'((" op" " analyze-last-stacktrace" ))
500
535
(cider--nrepl-print-request-map fill-column))
501
536
(seq-mapcat #'identity ))
502
537
(lambda (response )
538
+ (nrepl-dbind-response response (phase)
539
+ (when phase
540
+ (setq ex-phase phase)))
503
541
; ; While the return value of `cider--handle-stacktrace-response' is not
504
542
; ; meaningful for the last message, we do not need the value of `causes'
505
543
; ; after it has been handled, so it's fine to set it unconditionally here
506
- (setq causes (cider--handle-stacktrace-response response causes))))))
544
+ (setq causes (cider--handle-stacktrace-response response causes ex-phase ))))))
507
545
508
546
(defun cider-default-err-handler ()
509
547
" This function determines how the error buffer is shown.
0 commit comments