On Nov 16, 8:33 am, Rich Hickey <[EMAIL PROTECTED]> wrote:
> I'm certainly interested in improving the error reporting, but in this
> partiicular case:
>
>  java.lang.ClassCastException: clojure.lang.LazyCons
>
> is my all-time pet-peeve exception message, and it comes from the JVM.
> Why on earth they didn't report the types of both what you had and
> what you were trying to cast to is completely baffling and can only be
> described as a bug, which seems to be fixed in JDK 6, which reports
> "XXX cannot be cast to YYY".

Nice to know this has a solution.  Two other messages spring to mind
as tricky to diagnose, don't know if the JVM makes it possible to
improve them:

1. NullPointerException: Where did it come from?  What was null?  This
is tough, since the nil could have been returned by some distant
function.  Probably not easy to fix.

2. user=> (BigDecimal/valueOf 2)
java.lang.IllegalArgumentException: No matching method found: valueOf

The problem there is that BigDecimal.valueOf takes only a double or
long, not an Integer.  This is pretty uncommon in the standard Java
APIs, but some libraries have the same method repeated with a bunch of
different argument types.  Often it's hard to figure out why Clojure
can't find the right method.  Not sure exactly how to make this
easier, maybe if the error reported the full method signature it was
trying to find, e.g. "No matching method found valueOf
(java.lang.Integer)"

-Stuart Sierra
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to