Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Recover from errors more nicely. #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcomorain
Copy link
Contributor

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

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 avli#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 avli#112
@marcomorain
Copy link
Contributor Author

Before

undefined

After

compilation_error

@marcomorain
Copy link
Contributor Author

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
Copy link
Owner

avli commented Aug 5, 2018

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
Copy link
Contributor Author

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

@avli avli force-pushed the master branch 2 times, most recently from 7e1c85a to 068abc8 Compare November 8, 2022 15:35
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Absence of error messages from external nREPL
2 participants