Function: cider--handle-stacktrace-response

cider--handle-stacktrace-response is a byte-compiled function defined in cider-eval.el.

Signature

(cider--handle-stacktrace-response CAUSES EX-PHASE SOURCE-BUFFER)

Documentation

Handle stacktrace response provided as aggregated CAUSES.

For EX-PHASE that represents compilation errors, don't show *cider-error* buffer but render an error overlay instead in the SOURCE-BUFFER. For others, pop up *cider-error* buffer.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-eval.el
(defun cider--handle-stacktrace-response (causes ex-phase source-buffer)
  "Handle stacktrace response provided as aggregated CAUSES.
For EX-PHASE that represents compilation errors, don't show *cider-error*
buffer but render an error overlay instead in the SOURCE-BUFFER.
For others, pop up *cider-error* buffer."
  ;; Handle special "notification" server messages.
  (dolist (cause causes)
    (nrepl-dbind-response cause (msg status type)
      (when (member "notification" status)
        (nrepl-notify msg type))))
  ;; Render stacktrace in *cider-error* buffer if it is a runtime error.
  (cider--render-stacktrace-causes
   causes nil (member ex-phase (cider-clojure-compilation-error-phases))
   (with-current-buffer source-buffer (cider-current-repl)))
  ;; If the error is a compilation error (which we normally don't show
  ;; *cider-error* buffer for), or the error buffer is disabled, compensate for
  ;; the lack of info with a overlay error. Verify that the provided buffer is
  ;; not a REPL buffer but either visits a Clojure source file or is
  ;; e.g. cider-scratch.
  (when (and source-buffer
             (with-current-buffer source-buffer
               (or (cider-clojure-major-mode-p)
                   (cider-clojurec-major-mode-p)
                   (cider-clojurescript-major-mode-p)))
             (or (member ex-phase (cider-clojure-compilation-error-phases))
                 (not (cider--show-error-buffer-p))
                 (not (cider-connection-has-capability-p 'jvm-compilation-errors))))
    ;; Search if any of the received causes contains a "triage" field. Append it
    ;; to the inline error message if found.
    (let* ((triage (seq-some (lambda (cause) (nrepl-dict-get cause "triage")) causes))
           (err-message (mapconcat (lambda (cause) (nrepl-dict-get cause "message"))
                                   causes "\n"))
           (err-message (if triage
                            (concat err-message "\n" triage)
                          err-message)))
      (cider--display-error-unobtrusively source-buffer err-message))))