Fork me on GitHub
#cider
<
2018-04-23
>
jumblemuddle01:04:45

Is there any way to get cider to show (.printStackTrace error)'s result in other threads as a normal stacktrace?

jumblemuddle01:04:00

I don't like having to look at the repl to see the error.

jysandy03:04:48

I’ve not been able to see logs in cider. This is using cider-nrepl 0.17.0-SNAPSHOT. My application is logging to STDOUT. There’s no *nrepl-server* buffer or anything similar. How might I go about debugging this? I know that the application is logging correctly. The logs show up when I run code in the Cursive REPL. Note that I’m quite ignorant when it comes to emacs things. Side by side, is there a way to tell cider not to use SNAPSHOT versions of cider-nrepl?

bozhidar04:04:48

@jumblemuddle I’m not sure I’m understanding the problem you have and what you want to achieve.

bozhidar04:04:53

@jysandy Generally such logs end up in the nrepl-server buffer and should also be doubled in your REPL. Are you on the most recent snapshot? Well, if you don’t use snapshot versions of cider-nrepl with a snapshot version of CIDER, it’s not going to work. 🙂 You can always use some repo like melpa-stable and the latest stable release instead.

jumblemuddle20:04:11

@bozhidar Cider only handles errors that are bubbled up to the main thread (I assume this has something to do with the way the nrepl middleware is setup.) Is there a way to get it to handle/pretty-print stacktraces that are printed from other threads? Unfortunately there isn't a good way for me to get the errors to be thrown on the main thread, so I have to resort to (try ... (catch Exception e (.printStackTrace e))) at the moment.

dominicm20:04:09

I can't think of a way right now, but I could think of some magical ways to do it... 🤔

jumblemuddle20:04:59

Haha, if you've got some wizardry that'd be cool. It's really only a problem, because I'm diving into the messy world of ugly java libraries.

tanzoniteblack20:04:14

a minimumly viable way to do it: (catch Exception e (def crap-an-error e)) (or use an atom or something mutable) and then from the repl, just do (throw crap-an-error)

jumblemuddle20:04:07

Oh, catch errors and set them in a watched atom or something is an idea.

dominicm20:04:15

Cider could add a tag for this, but I've not thought much about that

tanzoniteblack20:04:31

but I'm just guessing

dominicm20:04:06

Yeah, similar code transformation could take place to catch the exn

dominicm20:04:23

Or setting an unhandled exception handler

jumblemuddle22:04:41

Thanks for the suggestion, @tanzoniteblack. I've gone ahead with (catch Exception e (reset! error e)) then I just evaluate #_(throw @error) when I need to see the error. It's not pretty, but it works alright.