Nice work! Maybe asking the obvious here, but this library only "rephrases" the error message, right? I checked the source but wasn't sure.
Is there an intention to make it more broad, let's say
• suggest exact fixes based on a schema in the metadata
• Trimming the stacktrace elements that have no added value (when it is known error I think this can be safe)
I guess there are some answers here https://clojurians.slack.com/archives/C0B2UH1BPT3/p1778379353495639 You remove the stacktrace when it is not needed. And you make some suggestion of how to fix it. I'm also thinking of schema errors like with Malli. An error can be overwhelming but can many times be nicely printed if you have a schema and the original data. Probably out of scope, but maybe there could be some kind of plugin system that rephrase can help to print friendly errors also for libraries
I read the README on my laptop instead of my phone and it became more clear to me what Rephrase does. So now I understand you remove the stacktrace entirely. From my own experiments I have experienced that it is sometimes hard to remove stacktrace information without losing information. I will give rephrase a try to see how you do it! Thank you for releasing it
Sorry I just deleted my own replies to this message. I think i'm only half awake. Your README is perfectly clear. Thanks for releasing it! I will give it a try.
I've also experimented a bit with making errors more accessible. For me one challenge is often going through the stacktrace and seeing the code. By the error message, from experience, most of the time I can often quickly tell what is wrong, but then I also need to lookup the where and sometimes the why if it is a more complicated bug. So I haven't focussed on the what that much. I think Rephrase will be a nice improvement for me.
Questions...for I don't quite understand how to get it to work. I have this as my nrepl middleware (output directly, when I launch clojure)...
[#'org.corfield.rephrase.nrepl/wrap-rephrase
#'cider.nrepl/wrap-apropos
#'cider.nrepl/wrap-classpath
#'cider.nrepl/wrap-clojuredocs
#'cider.nrepl/wrap-complete
#'cider.nrepl/wrap-content-type
#'cider.nrepl/wrap-debug
#'cider.nrepl/wrap-enlighten
#'cider.nrepl/wrap-format
#'cider.nrepl/wrap-info
#'cider.nrepl/wrap-inspect
#'cider.nrepl/wrap-log
#'cider.nrepl/wrap-macroexpand
#'cider.nrepl/wrap-ns
#'cider.nrepl/wrap-out
#'cider.nrepl/wrap-slurp
#'cider.nrepl/wrap-profile
#'cider.nrepl/wrap-refresh
#'cider.nrepl/wrap-reload
#'cider.nrepl/wrap-resource
#'cider.nrepl/wrap-spec
#'cider.nrepl/wrap-stacktrace
#'cider.nrepl/wrap-test
#'cider.nrepl/wrap-tap
#'cider.nrepl/wrap-trace
#'cider.nrepl/wrap-tracker
#'cider.nrepl/wrap-undef
#'cider.nrepl/wrap-version
#'cider.nrepl/wrap-xref]at the repl, I then do this (as an experiement)
user=> (defn foo [x] (println x))
#'user/foo
user=> (foo)
Execution error (ArityException) at user/eval54064 (REPL:1).
Wrong number of args (0) passed to: user/fooI was expecting "Wrong number..." to be replaced with the more friendlier wording.
this is probably a PEBKAC 🙂
(no change if I move wrap-phrase to the end of the list)
Ahhh, i see
Okay, I understand.
Would love to hear what you learned!
ah, you're right. I got confused (again!) between nrepl sessions, which vim hooks into (via conjure) and repl sessions, which I use too
so, the rephrase error messages do appear correctly, if I eval the form in my vim buffer
it's on the command line repl, that's where they do not appear - but that doesn't bother me 🙂
Hope that explains it adequately 🙂
Yeah, all good @dharrigan, thanks! I just haven't tried rephrase yet and was curious what you stumbled on.
I use Rebel Readline's nREPL client, so it connects to the same nREPL server with all the middleware, and so I get nice interactive Rebel stuff + nice rephrased exceptions.
I teoo use rebel readline, although my setup does inject afew more things
The key is using the new client, not the regular Rebel cmdline:
(!2016)-> cat `which repl`
...
clojure "$@" -M:1.13:allow-attach-self:portal:test:cider-nrepl:rebel:dev/repl
(2026-08-06.12:00:05)-(~/clojure)
(!2017)-> repl
Starting Rebel Readline Client + nREPL Server with Rephrase, Portal, Notebook, CIDER as the REPL...
nREPL server started on port 39147 on host 127.0.0.1 -
Connecting Rebel Readline to nREPL server on port 39147...
[Rebel readline] Type :repl/help for online help info
user=> (defn foo [x] (println x))
#'user/foo
user=> (foo)
user/foo was called with no arguments, but it requires at least one argument, at user/eval19286 (REPL:1) - runtime error (incorrect number of arguments).
user=>
Note: Rebel Readline Client there.With that setup, I get the "Wrong number of args..."
Would be curious to see yours 😉
ohhh
I'll have a play 🙂
[Rebel readline] Type :repl/help for online help info
user=> (defn foo [x] (println x))
#'user/foo
user=> (foo)
user/foo was called with no arguments, but it requires at least one argument, at user/eval59595 (REPL:1) - runtime error (incorrect number of arguments).
user=>🙂
I never knew you could connect rebel readline to nrepl
TIL! thanks!
It's a new feature. Earlier this year I think?
sweet
@seancorfield, rephrase looks pretty neat. I don't get a quick sense of what it does from the README yet. Do you think it would be helpful to show before-and-after examples in the README? Happy to raise an issue if you think this would be helpful (and also take a crack at a PR, if that's interesting).
Sean, I'm reviewing the docs from a beginner's perspective. It's a bit of a tricky thing, maybe? Rephrase is supposed to help beginners, but setting up rephrase might not be so easy for beginners. The typical usage would be as nREPL middleware... but I'm guessing most beginners will be jacking in from their IDEs? Is jack-in config IDE-specific? Should we describe how to setup for Calva, for example?
Perhaps a mention (tip) of clj-kondo linter (via clojure-lsp) would be helpful too. Rephrase will help in understanding exceptions, but kondo will help to, at least somewhat, avoid exceptions in the first place.
(Am not a Calva user, am taking a peek at how its jack-in works.)
(Ah... cool, in Calva, you can pick aliases to launch with)
I talked to @pez and he was considering an option in Calva that could add the Rephrase dep and middleware, like it already does for nREPL/CIDER/etc. But, yeah, setting it up is an area that currently needs a lot more hand-holding. My REPL setup is rather different to most people so I haven't really known what to add to the README for "normal" setups. nREPL / CIDER middleware is a non-trivial setup for beginners, if the IDE doesn't expose deps etc.
I can take a shot at updating rephrase README here, if you like. I'd focus on Calva to start with.
@pez, I think I'd kinda explain it https://calva.io/reveal/#middleware.
Cool. I’ll be happy to provide feedback.