avli / clojureVSCode

Clojure support for Visual Studio Code
https://avli.github.io/clojureVSCode/
MIT License
204 stars 34 forks source link

Recover from errors more nicely. #114

Open marcomorain opened 6 years ago

marcomorain commented 6 years ago

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 commented 6 years ago

Before

undefined

After

compilation_error

marcomorain commented 6 years ago

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.

avli commented 6 years ago

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 :-)

marcomorain commented 6 years ago

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