Adopt more error reporting features available in Clojure 1.10+ #3338
Replies: 9 comments 15 replies
-
There's a bit of backstory here #2443 for whoever is interested. CIDER stacktrace functionality predates Clojure 1.10 by a few years and we never made a focused effort to update it once those changes landed for various reasons. In general I agree it'd better to support properly the extra info added in Clojure 1.10, so contributions in that direction would be most welcome. Back when it was introduced it was hard to parse Clojure (EDN) in Emacs, but that problem was solved by |
Beta Was this translation helpful? Give feedback.
-
@daveliepmann thanks for opening this, I'd love to see things improved in cider as well. Somewhat related, I've noticed that if I augment and rethrow an Exception (using ex-cause) my cider will only show the cause, not the more useful original exception that's thrown: If I collapse the cause and expand the original exception it looks good:
|
Beta Was this translation helpful? Give feedback.
-
Just pointing out that there's a configuration setting Here's what that looks like when successively eval-ing forms from the buffer (note: |
Beta Was this translation helpful? Give feedback.
-
@yuhan0 👍🏻 that was it, yeah. I wasn't thinking of this as a solution to the problem statement at the start of the thread, but I did want to try out that setup because I might prefer the ergonomics of a brief, persistent, in-place error message. :) |
Beta Was this translation helpful? Give feedback.
-
I'm interested in revisiting this with some concrete solutions which are within easy reach. It's possible I have tunnel vision for the idea of an error summary so it would be good to see alternatives, or to flesh out the idea. Setting aside radical UI changes and existing workarounds using different configs: what is the simplest change which would address any of the examples from Alex's list? For instance, how easy/hard would it be to provide a summary in the existing |
Beta Was this translation helpful? Give feedback.
-
I've created #3418 which seems to me a very minimalistic and effective way of tackling 90% of the problem. To be honest, I don't believe this typically is a "stacktrace" problem. A stacktrace is not the best medium of conveying The good news is, as seen in the #3338 (comment) screenshot, CIDER already does a more than decent job at summarizing the issue and presenting it with a concise, overlay-based UI. So, we just need to dynamically choose when, and when not to, display stacktraces. That's what #3418 is about. Still, there are some nice to haves though:
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Today's round of input has been much useful, both in new info we've provided confirming the current/intended behavior starting from 1.8.0, and pointing out some necessary tweaks (many of which are already in transit). Other than that, I'll lock this discussion simply b/c it's completed - I wouldn't want it to become a catch-all for future development. |
Beta Was this translation helpful? Give feedback.
-
Since Clojure 1.10, Clojure provides ways to greatly improve error reporting in REPL tools. As today's standard-bearer for interactive development, CIDER should take full advantage of these new capabilities.
Problem Statement
People consider error messages the top reason Clojure isn't more popular than it is, and the most important area of improvement for the Clojure experience. Year after year in the annual State of Clojure survey, the community ranks "error messages" a top priority for improvement and a major source of frustration:
When introducing people to programming in Clojure, long and complicated stacktraces are a leading complaint. Experienced Clojurians often don't feel it so acutely, but obscure stacktraces are a pain point in the Clojure experience.
Regarding Clojure tooling, CIDER is top dog. It is the most popular Clojure development environment, so a lot of the bad experiences with Clojure errors happen in CIDER.
New possibilities
For a long time, a better error message experience was impossible (or prohibitively difficult) due to limitations in the language itself: an error produced stacktraces with mostly Strings instead of data. As of Clojure 1.10, this is no longer the case: Clojure now categorizes errors, returns information about the error as consistent
ex-data
, and provides functions likeex-triage
,ex-str
, andThrowable->map
.The clojure.main REPL takes advantage of these, making many error messages extremely useful and concise. Alex Miller helpfully provided a short list of examples:
:::5
- error during reading(let [x])
- error during macroexpansion caught by a macro spec(cond 1)
- error during macroexpansion thrown by the macro(defmulti 5 class)
- unexpected error during macroexpansion(def 5)
- compilation error(/ 1 0)
or (+ 1 :a) - evaluation error(deftype T [a])
(defmethod print-method T [_ w] (throw (Exception. "boom")))
(->T 1)
- printing errorThe first of that list (
:::5
) doesn't look too bad in my CIDER, because the stacktrace isn't long and some of it is minimized.The second,
(let [x])
, looks like this in the Clojure CLI:Short and to the point. If I run the same in CIDER's REPL buffer, I get almost the same result...but that's not how I work. I almost never enter forms into the REPL buffer. Like many Clojurians, I prefer to work in an interactive style, sending forms from namespace buffers. With this, the CIDER error experience is not good:
The relevant part doesn't even fit on my screen:
How can we provide a nicer, more concise CIDER error UI?
Beta Was this translation helpful? Give feedback.
All reactions