-
Notifications
You must be signed in to change notification settings - Fork 47
better error messages #77
Comments
@carocad What REPL are you using? Whatever it is, it's certainly outputting a briefer 'stacktrace' tho it only seems marginally more informative (to someone not familiar with Clojure). That said, I think recent versions of Clojure have gotten some modestly improved stacktraces and error messages – maybe that's in clojure.stacktrace. So I imagine that we'd be open to replacing whatever library we're using now with something better. I'll gladly test out whatever you think might be a suitable change; submit a PR with the changes and I'll take a look at it. |
I would kind of preferred if we looken into what it would take to integrate something like Preferably with the proper formatting (and if possible with coloring, which probably won't be all that trivial... ) |
@rundis That library looks fantastic. |
@kenny-evitt I'm using
I will try to hack my clojure plugin to see if I can change the nrepl exeption formatting that we currently have. @rundis that's great, but I don't see why we should choose one over the other. From my point of view it would be better to have levels of stacktrace. For the beginner it would probably be better to have a very simple error message like the one from clojure.stacktrace whereas some advance users might want to have more details about it like the ones in aviso/pretty. From what I see in the aviso/pretty source code it is perfectly possible to pass a normal stacktrace and get the pretty formatted one. |
@carocad With regard to pretty, while it provides for ways to customize what exceptions are elided in the output, the defaults seem pretty reasonable:
I can't tell from the REPL-y README or its project.clj file, what it's using that would improve its stacktraces. In fact it seems to be using clj-stacktrace too. Or are you somehow using clojure.stacktrace instead? |
Correct me if I'm wrong, but what I think @carocad is trying to get at is that rather than always printing the entire stacktrace, it should be optional if you wish to see just a summary (message/root cause) or the entire stacktrace (elided with clj-stacktrace or pretty). The current behaviour of Light Table is to always shows the entire stack on the line below the when showing inline-errors. It also shows the root-cause/message in the statusbar, but that disappears after about 5 seconds (if you blinked you missed it sorta'). The statusbar message is not far off the message that @carocad implies he would want to be shown inline I think. This is the relevant behavior that shows the exception on the cljs side of things in the Clojure plugin: So it would be really neat if inline-error were expandable (like inline results are), such that default it shows just the root-cause, and if you click on it, it expands to also show the full details). I see several different implementation alternatives with different scope: A) Simplest option - User configurableMake it a user setting to show either the stacktrace or just the root-cause in the above mentioned cljs behavior in the clojure plugin. B) Expandable inline exceptionShow root cause by default, allow user to expand inline exception to show details. If we change the default inline-exception widget, it would obviously have to be backwards compatible since it's use from many places and many different plugins. C) Expandable inline exception with better stacktrace formattingSimilar to B, but maybe swap clj-stacktrace for pretty. That means making changes to the lt nrepl middleware as well obviously |
@kenny-evitt I actually have no idea which part is the one that is trimming the stacktrace. I almost always work in LT so I didn't bother to check it until I figured out that tryclojure had such nice error messages; which later led me to clojure.stacktrace @rundis is completely right. My initial thought was only the simplest option (user configurable) but your other options do look very appealing. I'm willing to work on this if somebody can take the time to time to help me around on complicated (not-documented) stuff. Correct me if I'm wrong but all those changes would imply changing the lt nrepl middleware here right? |
Hi @carocad. Having no stacktrace isn't clearer or helpful for more experienced users and makes debugging near impossible for all users. I would rather not have that be a configurable option for users. I'm open to options B or C that @rundis proposed. It's worth noting that with behaviors and the User plugin you can implement no stacktrace for yourself without having to modify the Clojure plugin:
|
@cldwalker oh this is awesome! . Sorry for my ignorance but I was not aware that I could combine things in this manner. Thanks so much for the advice on implementing my own exception behavior. Thanks to the info that you gave me I was able to modify the exeption a little bit and figure out a tiny way to improve its current behavior without much of a change. I will submit a pull request about it. |
Hey guys, I wrote "implementation" because it is in fact an almost exact copy of inline.result. The differences are only its display (text and background color) and its menu behavior. For brevity I put everything in the same gist. The intention was mainly to show it. I have tested this behavior on my Lighttable and it works fine but to be honest I don't understand completely the code used for both the inline.exception and the inline.result so I don't know if implementing it this way could cause any colateral effect. Thus I would like you to check it out. I could also create a plugin for it but I would prefer this to be the default exception-display behavior of clojure. Let me know what you think |
Cool ! Do you have screenshot of how it looks truncated and expanded ? I have a feeling that the expanded view might be lacking in terms of formatting ? I think maybe you need to use a pre tag or something to keep formatting. However that comes add odds with the truncate feature. A better solution might be allow the new exception display behaviour to take a summary and details argument. Details could be hidden default, and when clicking, details becomes visible (simple css visibility toggle ?). One of the reasons that exceptions are shown underline (rather than to the right), is that stack traces tend to be quite wide. Actually the current display of stack traces doesn't work well with narrow tab sets (no scroll). I think it would be best too keep exception display as an underline result. A summary of thoughts going forward:I think I'd prefer if the new behavior for adding a toggle-able error display be added to eval.cljs. This way future plugins (or upgrade of existing plugins) may start to gradually use the new behavior whilst old plugins can happily work with the old behavior. @carocad would you be willing to submit a pull-request to LT core for a new error display behavior (taking into account the considerations mentioned above) ? @cldwalker agreed ? |
Hey @rundis here are the screenshots of the collapsed and expanded exception. The lines are displayed with the correct formatting except those that are longer than the exception box; those end up in several (unformatted) lines, as you can see in the screenshoot. I would gladly submit a pull-request with the new behavior but as I said, I don't have a good knowledge of what is the complete inline-result behavior/object code doing, thus I would prefer if @kenny-evitt or @cldwalker take a first look at it before trying to properly style it. |
@rundis I'm open to this feature as long as we make this an opt-in behavior and preserve existing behavior as the default - full stacktrace is viewable. Once we use it more and possibly get feedback from other users, we can see if it makes sense to change the default behavior. As for where we want the new widget to live, I'm ok w/ either LT or the plugin. It may be helpful to have it live in the plugin first for quicker iteration and to work out any bugs but it's up to you |
@cldwalker You've convinced me :-) Let's add it to the Clojure plugin only for now. @carocad Let's do as follows;
|
@rundis
Here you can find the new code: https://gist.github.com/carocad/7b17d71443e842938edc Here are some screenshots of the new behavior: If this is ok like that I would proceed to create the new namespace and submit the patch. |
@carocad Sorry for the late reply |
oh I just discovered the first bug in this implementation. It turns out that result-mark fixes max-height to 50% so it need to be changed to "initial" to avoid hidden parts of very long stacktraces. The change is minimum:
|
collapsible exceptions added in a new namespace, according to #77
@kenny-evitt @rundis @cldwalker is anyone interested in mentoring the development of aviso/pretty as the standard stacktrace tool for Clojure's plugin? I am willing to work on it but I don't have as much experience as you guys so, some help would be much appreciated. |
hey guys @kenny-evitt @rundis, Here is a gist with the change proposal to replace clj-stacktrace with aviso/pretty. I think that all functionality would remain the same since I only touched the stacktrace-string parsing part. Nevertheless I would like to know your opinion about it, you know more about it than me anyway ;) Here is a snapshot of the result. PS: I avoided putting colors to the output as that would require quite some more effort and possibly create a dependency between how are stacktraces parsed in |
It seems I was wrong and putting colors on the output was not that difficult as I thought at the beginning. I avoided stripping away the ansi codes from the stacktrace (here) and I created a parser from ansi-code to hiccup, which did the job perfectly :). The parser can be integrated with the previous collapsible exception behavior without any troubles (see specific lines here) |
@carocad Fantastic! I'm not ecstatic about those particular colors. Could you look at trying to match them with existing colors (assuming we have defined colors to which you can match)? As-is tho, there's no reason not to create a pull request with your changes. I think everyone would be happy commenting on your code that way. |
Hey guys,
I was checking around what I thought was normal behavior for clojure and found out that it is probably a Lighttable thing. My problem is that any error that occurs in Lighttable creates a stack trace which is unreadable. For example:
on the REPL produces:
Whereas on my Lighttable produces:
I don't know if this behavior is only on my Lighttable version but I guess not.
On the other hand I saw that you use clj-stacktrace in nrepl/exception.clj which is a user specific code. Have you checked clojure.stacktrace from Clojure itself?
In tryclojure they use it and it is extremely simple; you can see the relevant lines here
Let me know your thoughts about it
The text was updated successfully, but these errors were encountered: