error messages?

3 views
Skip to first unread message

Raoul Duke

unread,
Aug 11, 2008, 2:58:14 PM8/11/08
to clo...@googlegroups.com
hi,

i'm pretty clueless about how hard it would be, i'm figuring it can
get arbitrarily complicated and expensive and time sinky, but i'd like
to make a small note about error messages from Clojure -- they seem to
be sometimes more complicated or intimidating or unhelpful than a
newbie such as myself might benefit from :-)

one example is that stack traces come out a lot and can obfuscate the
real issue. so even though there is an error which might be helpful
enough to figure out what the fix is, it might scroll away due to the
stack dump, and the stack dumps can be scary in and of themselves.
(see below).

there are other things i think i've seen but don't have examples
available right now: i think i've seen errors which were pretty far
away from the actual underlying cause in terms of what line they said
the error was on (like one i think said error on like 224 when i only
had like 10 lines in the program); or in terms of the concept involved
(like some scary compiler-internal-looking error for mismatched parens
or whatever).

user=> (defn foo [] (let [d1 (Date)] d1))
java.lang.Exception: Unable to resolve symbol: Date in this context
clojure.lang.Compiler$CompilerException: NO_SOURCE_FILE:1: Unable to
resolve symbol: Date in this context
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3364)
at clojure.lang.Compiler.analyze(Compiler.java:3296)
at clojure.lang.Compiler.access$200(Compiler.java:37)
at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:3125)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3357)
at clojure.lang.Compiler.analyze(Compiler.java:3296)
at clojure.lang.Compiler.analyze(Compiler.java:3271)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3346)
at clojure.lang.Compiler.analyze(Compiler.java:3296)
at clojure.lang.Compiler.analyze(Compiler.java:3271)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:3022)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:2889)
at clojure.lang.Compiler$FnMethod.access$1100(Compiler.java:2800)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:2523)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3355)
at clojure.lang.Compiler.analyze(Compiler.java:3296)
at clojure.lang.Compiler.analyze(Compiler.java:3271)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3346)
at clojure.lang.Compiler.analyze(Compiler.java:3296)
at clojure.lang.Compiler.access$200(Compiler.java:37)
at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:324)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3357)
at clojure.lang.Compiler.analyze(Compiler.java:3296)
at clojure.lang.Compiler.analyze(Compiler.java:3271)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3346)
at clojure.lang.Compiler.analyze(Compiler.java:3296)
at clojure.lang.Compiler.analyze(Compiler.java:3271)
at clojure.lang.Compiler.eval(Compiler.java:3384)
at clojure.lang.Repl.main(Repl.java:75)
Caused by: java.lang.Exception: Unable to resolve symbol: Date in this context
at clojure.lang.Compiler.resolveIn(Compiler.java:3471)
at clojure.lang.Compiler.resolve(Compiler.java:3446)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:3431)
at clojure.lang.Compiler.analyze(Compiler.java:3284)
at clojure.lang.Compiler.analyze(Compiler.java:3271)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:2421)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3359)
... 29 more

mac

unread,
Aug 12, 2008, 1:32:04 AM8/12/08
to Clojure
I can sort of agree with you, there is a lot of text. But generally
the most interesting stuff is at the top of the stack trace, the rest
is usually just side effects of the error. With that in mind I think
it's much less intimidating, just scroll up to see what really
happened.
Also if you keep an eye on the "at ..." lines you can usually spot the
name of one of your own functions in there which makes it easier to
track the error if the top of the stack trace does not make sense
right away.
I know it's not a "fix" but that's how I analyze the stack traces and
I've gotten pretty comfy with it.

/mac

Parth Malwankar

unread,
Aug 12, 2008, 2:37:21 AM8/12/08
to Clojure
Raoul Duke wrote:
> hi,
>
> i'm pretty clueless about how hard it would be, i'm figuring it can
> get arbitrarily complicated and expensive and time sinky, but i'd like
> to make a small note about error messages from Clojure -- they seem to
> be sometimes more complicated or intimidating or unhelpful than a
> newbie such as myself might benefit from :-)
>

Yes. I agree, it was a little intimidating for me too as Clojure
newbie
who doesn't know Java.

But the trick is to just look at the relevant lines and ignore the
rest
as white-noise.
In this case:

user=> (defn foo [] (let [d1 (Date)] d1))
java.lang.Exception: Unable to resolve symbol: Date in this
context
clojure.lang.Compiler$CompilerException: NO_SOURCE_FILE:1: Unable
to
resolve symbol: Date in this context

I suppose the intent of the entire stack trace is to help the Clojure
developers debug any bugs / issue found easily.

What might be nice though is to have a verbosity flag that can be
used
to turn off messages related to Clojure internals.

Allen Rohner

unread,
Aug 13, 2008, 11:47:47 PM8/13/08
to Clojure
> > i'm pretty clueless about how hard it would be, i'm figuring it can
> > get arbitrarily complicated and expensive and time sinky, but i'd like
> > to make a small note about error messages from Clojure -- they seem to
> > be sometimes more complicated or intimidating or unhelpful than a
> > newbie such as myself might benefit from :-)
>
> Yes. I agree, it was a little intimidating for me too as Clojure
> newbie
> who doesn't know Java.
>
> But the trick is to just look at the relevant lines and ignore the
> rest
> as white-noise.
> In this case:
>

Out of curiosity, I tried grepping the stack trace for .clj and the
result was pretty useful. Here an example from my little compojure
app.

kjata:compojure arohner$ ./script/repl
clojure.lang.Compiler$CompilerException: /Users/arohner/Programming/
clojure/compojure/lib/compojure/html/html.clj:6: No such namespace:
lib
at clojure.lang.Compiler.analyze(Compiler.java:3669)
at clojure.lang.Compiler.analyze(Compiler.java:3627)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:2626)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3816)
at clojure.lang.Compiler.analyze(Compiler.java:3654)
at clojure.lang.Compiler.analyze(Compiler.java:3627)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:3340)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:3187)
at clojure.lang.Compiler$FnMethod.access$1200(Compiler.java:3098)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:2729)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3812)
at clojure.lang.Compiler.analyze(Compiler.java:3654)
at clojure.lang.Compiler.eval(Compiler.java:3845)
at clojure.lang.Compiler.load(Compiler.java:4138)
at clojure.contrib.lib.load_resource__2207.invoke(lib.clj:303)
at clojure.contrib.lib.load_one__2173.invoke(lib.clj:201)
at clojure.contrib.lib.load_lib__2197.doInvoke(lib.clj:265)
at clojure.lang.RestFn.applyTo(RestFn.java:147)
at clojure.apply__135.doInvoke(boot.clj:364)
at clojure.lang.RestFn.invoke(RestFn.java:460)
at clojure.contrib.lib.load_namespaces__2214.doInvoke(lib.clj:388)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.apply__135.doInvoke(boot.clj:364)
at clojure.lang.RestFn.invoke(RestFn.java:460)
at clojure.contrib.lib.use__2224.doInvoke(lib.clj:453)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at user.eval__2230.invoke(boot.clj:5)
at clojure.lang.Compiler.eval(Compiler.java:3847)
at clojure.lang.Compiler.load(Compiler.java:4138)
at clojure.lang.Compiler.loadFile(Compiler.java:4103)
at clojure.lang.Repl.main(Repl.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
at jline.ConsoleRunner.main(ConsoleRunner.java:69)
Caused by: java.lang.Exception: No such namespace: lib
at clojure.lang.Compiler.resolveIn(Compiler.java:3950)
at clojure.lang.Compiler.resolve(Compiler.java:3928)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:3911)
at clojure.lang.Compiler.analyze(Compiler.java:3642)
... 37 more

and after grepping:

compojure/lib/compojure/html/html.clj:6: No such namespace: lib
at clojure.contrib.lib.load_resource__2207.invoke(lib.clj:303)
at clojure.contrib.lib.load_one__2173.invoke(lib.clj:201)
at clojure.contrib.lib.load_namespaces__2214.doInvoke(lib.clj:388)
at user.eval__2230.invoke(boot.clj:5)

Allen
Reply all
Reply to author
Forward
0 new messages