Fork me on GitHub
#dev-tooling
<
2024-01-04
>
mauricio.szabo22:01:17

Folks, for nREPL: what exactly is nrepl.middleware.caught/caught? Basically, what I am trying to do, is to avoid printing to stderr when some exception happens - is it possible? Am I on the right track, or should I be doing something completely different?

jpmonettas00:01:13

I never used that caught middleware but from looking at the code, if that middleware is loaded then for every exception clojure.main/repl-caught will be called unless nrepl.middleware.caught/**caught-fn** is bound to something else. clojure.main/repl-caught will print to std-err. So I guess you can set that to nil like (set! nrepl.middleware.caught/*caught-fn* nil) and it shouldn't print to std-serr

jpmonettas00:01:38

Or just print to std-out with (set! nrepl.middleware.caught/*caught-fn* (fn [e] (println "ERROR ----" e)))

mauricio.szabo00:01:04

Yes, that was what I found too. Unfortunately, seems that not all implementations honor this key, so I'm not sure it'll be useful for me 😞

jpmonettas00:01:47

not sure I follow, wdym? I tried it on my cider setup, replacing the cought-fn and seams to work

mauricio.szabo00:01:09

Babashka still prints to stderr, for example, when an exception happens

jpmonettas00:01:25

oh I see bb, ok

mauricio.szabo00:01:15

Yeah, nREPL implementations I meant 😄