-
-
Notifications
You must be signed in to change notification settings - Fork 651
Description
Is your feature request related to a problem? Please describe.
The cider error buffer is a great way to make Clojure's exceptions more ergonomic to read. However, if they are thrown from a different thread, such as when fiddling with UI in a JavaFx thread, then Cider is unable to catch them such that they raise the popup error buffer.
Describe the solution you'd like
Some sort of mechanism by which I can hook exceptions in other threads to trigger the cider error buffer popup.
Describe alternatives you've considered
Currently, I got it working, here's what i did;
First I used a workaround suggested in the slack;
(defonce last-exception (atom nil))Then I assign a handler to Thread/setDefaultUncaughtExceptionHandler. Something along the lines of;
(when (System/getProperty "cider-dev")
(reset! last-exception exception)
(log/error :message "EMACS-CIDER-REPORT-EXCEPTION"))Then on the emacs side;
(defun joe/clojure-cider-throw-last-error ()
(interactive)
(cider-interactive-eval "\(throw @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)The key being cider-repl-preoutput-hook