REPL does not print stack trace in some cases

184 views
Skip to first unread message

Allen Rohner

unread,
Oct 11, 2008, 1:26:18 PM10/11/08
to Clojure
If you exercise the bug in my previous post about resultset-seq, the
repl will not print a stack trace, it will only print the name of the
exception and the message. The following patch modifies the repl to
print the stack trace.

Allen


Index: src/jvm/clojure/lang/Repl.java
===================================================================
--- src/jvm/clojure/lang/Repl.java (revision 1060)
+++ src/jvm/clojure/lang/Repl.java (working copy)
@@ -97,7 +97,10 @@
Throwable c = e;
while(c.getCause() != null)
c = c.getCause();
- ((PrintWriter) RT.ERR.get()).println(e instanceof
Compiler.CompilerException ? e : c);
+ if(e instanceof
Compiler.CompilerException)
+ e.printStackTrace((PrintWriter)
RT.ERR.get());
+ else
+ c.printStackTrace((PrintWriter)
RT.ERR.get());
stare.set(e);
}
}

Chouser

unread,
Oct 11, 2008, 3:36:15 PM10/11/08
to clo...@googlegroups.com
On Sat, Oct 11, 2008 at 1:26 PM, Allen Rohner <aro...@gmail.com> wrote:
>
> If you exercise the bug in my previous post about resultset-seq, the
> repl will not print a stack trace, it will only print the name of the
> exception and the message.

That's a feature! I recent one, no less.

Seriously, people were complaining about giant "meaningless" stack
traces at the REPL, so the default now is to just print the exception
itself. To get the stack trace after an exception has occurred, try:

(.printStackTrace *e)

--Chouser

Allen Rohner

unread,
Oct 11, 2008, 3:50:19 PM10/11/08
to Clojure
It's odd to me that that the stack traces were only removed in a few
instances. There are still plenty of places that do print traces.

I'm all in favor of getting rid of the "meaningless" stack traces,
once we have better error reporting.

Allen

On Oct 11, 2:36 pm, Chouser <chou...@gmail.com> wrote:

Chouser

unread,
Oct 11, 2008, 6:14:09 PM10/11/08
to clo...@googlegroups.com
On Sat, Oct 11, 2008 at 3:50 PM, Allen Rohner <aro...@gmail.com> wrote:
>
> It's odd to me that that the stack traces were only removed in a few
> instances. There are still plenty of places that do print traces.

Such as where? I haven't seen any at the repl in a while. If a .clj
file loaded from the command line throws an exception, then I see the
stack trace, but that's a sort of "batch mode" where I guess people
were less unhappy about the long stack trace.

--Chouser

Jim Menard

unread,
Oct 11, 2008, 6:41:33 PM10/11/08
to clo...@googlegroups.com

I see them all the time. I'm using the 20080906 download. Are you all
using the latest git/svn builds?

Jim

>
> --Chouser
>
> >
>

--
Jim Menard, ji...@io.com, jim.m...@gmail.com
http://www.io.com/~jimm/

Mike Hinchey

unread,
Oct 12, 2008, 8:19:35 PM10/12/08
to Clojure
Either of these work, but they are a lot of work for a convience
feature like *e:
(.printStackTrace *e *err*)
(.printStackTrace *e (java.io.PrintWriter. *out*))

This helps, so *e will have verbose printing in the REPL:
(defmethod print-method Throwable [#^Throwable t, #^java.io.Writer w]
(if *print-readably*
(.printStackTrace t (java.io.PrintWriter. w))
(.write w (str t)))
nil)

-Mike
Reply all
Reply to author
Forward
0 new messages