cider

Joseph Ferano 2025-11-08T07:24:45.880609Z

Hi, thank you for Cider, It's really amazing. I wanted to ask a question about the cider-error buffer. It's really good and it pops up as expected. However, I'm developing with a JavaFx/cljfx application and when exceptions occur in the thread "JavaFX Application Thread" because I did something wrong from the UI view, the exception only gets shown in the cider repl. I can still jump to lines in the stracktrace by clicking on them, but it would be nice to get the cider-error buffer since it's more featureful. Is this possible?

Joseph Ferano 2025-11-09T10:33:54.650869Z

Ok, so I got it to automatically throw exceptions for me. Using this function

Thread/setDefaultUncaughtExceptionHandler
I then have this snippet in the function handler
(defonce last-exception (atom nil))
... Further down      
 (if (System/getProperty "cider-dev")
         (do
           (reset! last-exception exception)
           (log/error :message "EMACS-CIDER-REPORT-EXCEPTION")
That message is important On the emacs side I found the hook cider-repl-preoutput-hook;
(defun joe/clojure-cider-throw-last-error ()
  (interactive)
  (cider-interactive-eval "\(throw @editor.error-reporting/last-exception\)"))

(defun joe/cider-repl-preoutput-hook (output)
  (if (string-match "EMACS-CIDER-REPORT-EXCEPTION" output)
      (progn
        (joe/clojure-cider-throw-last-error)
        "")
    output))

(add-hook 'cider-repl-preoutput-hook #'joe/cider-repl-preoutput-hook)
And it works. Exceptions from JavaFx threads (and probably any thread) now trigger the cider-error buffer

Joseph Ferano 2025-11-09T10:42:26.923369Z

https://github.com/clojure-emacs/cider/issues/3850

Joseph Ferano 2025-11-09T10:42:35.201309Z

Created the issue describing what I did

Joseph Ferano 2025-11-10T03:39:02.555419Z

I need to debounce it 🙂

☝️ 1
oyakushev 2025-11-08T12:40:11.098309Z

As a hack, I can suggest wrapping your UI code in (try ... (catch Exception ex (def -my-error ex) (throw ex)), and then if you want to view the exception with cider-error buffer, manually call (throw -my-error).

Joseph Ferano 2025-11-08T12:41:18.382369Z

Not a bad hack 😁

oyakushev 2025-11-08T12:41:48.534639Z

We used to have a way to convert stderr stacktrace output into viewable/clickable cider-error buffer, but it wasn't very reliable and added a lot of complexity

oyakushev 2025-11-08T12:42:32.913159Z

But overall, it would be an interesting idea to be able to "send" an error to cider-error. I would appreaciate if you created a feature request, we may actually do it someday

Joseph Ferano 2025-11-08T12:47:36.669769Z

Sure thing

❤️ 1
Joseph Ferano 2025-11-08T12:48:17.544589Z

Thanks for the reply

Karl Xaver 2025-11-08T17:02:28.362149Z

I see potential for another awesome cider-inspector view... :) [Offtopic: stumbling upon the new byte-buffer view made my day when I was fiddling with UDP. Thanks for the great work!]

❤️ 1
oyakushev 2025-11-08T17:37:04.151129Z

CIDER inspector already has a special view for Throwable objects, but it is still not as optimized as cider-error buffer. It is still more about navigating data. For example, it can't jump to source definition which is not really inspector's job.

yuhan 2025-11-08T18:48:32.850909Z

I faced this exact same issue recently with ring handlers running in a separate thread, and came up with essentially the same hack:

(defonce last-error_ (atom nil))

(defn wrap-error [handler on-error]
  (fn [req]
    (try (handler req)
         (catch Throwable t
           (reset! last-error_ t)
           (on-error req t)
           {:status 500
            :body (pr-str (ex-message t))}))))
and while debugging I'd just have (throw @app.handlers/last_error_) in a nearby comment form and eval it when needed

Karl Xaver 2025-11-08T19:50:15.465379Z

Oh! The Throwable view is so seemless that I didn't even notice 🙂 Jump to source on a stacktrace-as-data line looks like a good candidate for a (buffer agnostic) embark target/action, provided by the user, not cider.