clojureVSCode icon indicating copy to clipboard operation
clojureVSCode copied to clipboard

Recover from errors more nicely.

Open marcomorain opened this issue 7 years ago • 4 comments

There are two changes here.

Firstly, detect when the call to get a stacktrace fails with unknown-op - this indicates that the cider middleware to get stack traces is not loaded.

This lead to the second change: after I fixed the first issue (which is bug #112 I noticed that if you do not have the clojure stack trace middleware, you could not see the reason for compilation errors. So rather than get a stack trace when compilation fails, we can print the error message from the compilation operation.

This makes compilation errors take only 1 line on the output panel, which is much nicer.

Fixes #112

marcomorain avatar Jul 19 '18 22:07 marcomorain

Before

undefined

After

compilation_error

marcomorain avatar Jul 19 '18 22:07 marcomorain

Hrm, maybe the sort stack trace is not such a good idea. It makes sense for syntax errors, but not for the results of eval, where you want to see a full stack trace.

marcomorain avatar Jul 20 '18 09:07 marcomorain

Hi @marcomorain,

Great stuff as usual! I definitely see the problem this PR aims to solve, however I'd like to be sure we're on the same page. Which middleware are you talking about? I used the following project.clj to test the PR:

(defproject example-project "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.9.0"]],
  :plugins [[cider/cider-nrepl "0.15.1"]])

With this project config, when I try to eval random stuff as you did, I get a readable error in the evaluation results channel.

I bet I have seen the message from your "Before" gif before but can't recall in which context :-)

avli avatar Aug 05 '18 17:08 avli

I think this PR needs to be re-done, since it hides the stack-trace of evaluation errors, which makes debugging problems really hard.

(I want to hide the stack trace of compile errors only, and just show the syntax error)

I cant remember what the middleware is called, but it’s the one that allows you to send a stacktrace error to cider after an error occurs.

A lot of the time when I repl intonapos I don’t have cider loaded, only plain nrepl. This is often the case when apps are started with lein run rather than lein repl

marcomorain avatar Aug 07 '18 10:08 marcomorain