liquidz / vim-iced

Clojure Interactive Development Environment for Vim8/Neovim
https://liquidz.github.io/vim-iced/
MIT License
518 stars 35 forks source link

Show full stack trace in iced stdout, how? #414

Closed geekingfrog closed 2 years ago

geekingfrog commented 2 years ago

Hello. I can't figure out how to get the entire stack trace in the stdout buffer. I only get the last line, which isn't very helpful when it's deep inside some library code.

Here's a quick showcase:

(defn boom [x]
  (.substring x 2))

(defn parent-boom [x]
  (boom x))

(comment
  (parent-boom nil))

When evaluating the expression in the comment I get:

Execution error (NullPointerException) at testing-misc.core/boom (core.clj:13).
Cannot invoke "Object.getClass()" because "target" is null

Line 13 is the .substring bit. I would like to get the entire stack trace, showing parent-boom. For example, if I put a main function and run that, I get:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "target" is null
    at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:97)
    at testing_misc.core$boom.invokeStatic(core.clj:7)
    at testing_misc.core$boom.invoke(core.clj:6)
    at testing_misc.core$parent_boom.invokeStatic(core.clj:10)
    at testing_misc.core$parent_boom.invoke(core.clj:9)
    at testing_misc.core$_main.invokeStatic(core.clj:15)
    at testing_misc.core$_main.doInvoke(core.clj:12)
    at clojure.lang.RestFn.invoke(RestFn.java:397)
    at clojure.lang.AFn.applyToHelper(AFn.java:152)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at testing_misc.core.main(Unknown Source)

Which is what I'd like to see in the stdout buffer. Is there a way to get that?

liquidz commented 2 years ago

@geekingfrog Currently there is no way 😢 Using printStackTrace explicitly will show full stack trace to your REPL. (I did if I needed to)

(comment
  (try
    (parent-boom nil)
    (catch Exception ex
      (.printStackTrace ex))))

But indeed, it is a pain and I was hoping to show full stack trace too. It should be done by wrap-stacktrace middleware in cider-nrepl, so I'll try to do.

liquidz commented 2 years ago

OK. I could show full stack trace in stdout buffer for now.

2022-06-11 7 49 47
liquidz commented 2 years ago

@geekingfrog I've implemented in dev branch for trial. When exception occurs, vim-iced will do followings.

Could you try dev branch?

geekingfrog commented 2 years ago

Everything works as expected now. Populating the quickfix is a nice addition as well <3

liquidz commented 2 years ago

@geekingfrog Thanks for your confirmation! Just released v3.9.2 #416