This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-11
Channels
- # aleph (7)
- # announcements (5)
- # beginners (58)
- # calva (20)
- # cider (10)
- # clj-kondo (4)
- # cljfx (5)
- # cljsrn (7)
- # clojure (29)
- # clojure-europe (11)
- # clojure-mexico (1)
- # clojure-norway (26)
- # clojure-uk (9)
- # clojurescript (1)
- # cursive (31)
- # datahike (22)
- # datomic (12)
- # duct (3)
- # fulcro (28)
- # helix (35)
- # hyperfiddle (28)
- # lsp (4)
- # malli (8)
- # midje (3)
- # music (2)
- # nbb (9)
- # nrepl (20)
- # off-topic (36)
- # polylith (3)
- # shadow-cljs (47)
- # sql (2)
- # testing (7)
- # vim (17)
- # xtdb (7)
Does nREPL have something for displaying stacktraces, e.g. by sending over stack trace data? Right now the stacktrace with babashka + CIDER isn't very useful, but bb does have useful data that it could send to the client
This is how the exception now displays. The ex-data contains the interpreter stacktrace
The only built-in facility currently is ex-info
. cider-nrepl
has an additional stracktrace
middleware that can display structured stack traces, though. Both ex-info
and stacktrace
predate the addition of the rich ex-data
that was added around Clojure 1.10 if I recall correctly.
@U051BLM8F Let's start with the most simple thing though: how do I communicate the file, line and column of an error to an nREPL client in 2022?
Out of the box currently you can only supply an exception class and an error message for the failed eval:
(<--
id "25"
session "bdae3a62-a52e-46d4-959a-4ea1f6d1a735"
time-stamp "2022-08-12 09:31:02.571684633"
err "ArithmeticException Divide by zero clojure.lang.Numbers.divide (Numbers.java:158)
"
)
(<--
id "25"
session "bdae3a62-a52e-46d4-959a-4ea1f6d1a735"
time-stamp "2022-08-12 09:31:02.574206251"
ex "class java.lang.ArithmeticException"
root-ex "class java.lang.ArithmeticException"
status ("eval-error")
)
The expectation is that clients will parse the err
message and extract the filename and the location from it.
Probably it'd be nice if we made this more flexible and made it possible to return the map with exception metadata as well, so newer clients would use it instead. (e.g. there could ex-data
is the second eval-error
message)
The thing I'd be interested in is have a data-driven way to make CIDER highlight the error in the right location in the babashka script
CIDER parses the err message (using a regular expression) and uses it to highlight an entire line as the cause of the exception. In the presence of the stacktrace middleware it gets more precise data from it.
So if bb.nrepl printed the error in this format, it should work. I'll give that a try
in ArithmeticException Divide by zero clojure.lang.Numbers.divide (Numbers.java:158)
there is no reference to the user's clojure file where the error happened
Bad example I guess - for most exceptions there's actually file in which the exception was raised. Probably /
is defined in Numbers.java
.
Perhaps nREPL can work harder to find the most relevant frame of the stacktrace - I guess that was the top frame and that's what we use by default. I haven't looked at this code in ages, so I don't remember well how it works at this point.
Some examples from the tests in CIDER how we use this https://github.com/clojure-emacs/cider/blob/65a23e54227e3575f5a909dcfbdbbaef70d1438b/test/cider-error-parsing-tests.el