Here are the equivalent error messages in Clojure 1.8. I'm glad to see Java exception class names removed from error messages.
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_91-b14
user=> :::5
RuntimeException Invalid token: :::5 clojure.lang.Util.runtimeException (Util.java:221)
user=> (let [x])
IllegalArgumentException let requires an even number of forms in binding vector in user:1 clojure.core/let (core.clj:4333)
user=> (cond 1)
IllegalArgumentException cond requires an even number of forms clojure.core/cond (core.clj:589)
user=> (defmulti 5 class)
ClassCastException java.lang.Long cannot be cast to clojure.lang.IObj clojure.core/with-meta--4375 (core.clj:217)
user=> (def 5)
CompilerException java.lang.RuntimeException: First argument to def must be a Symbol, compiling:(/tmp/form-init3466436612016038338.clj:1:1)
user=> (/ 1 0)
ArithmeticException Divide by zero clojure.lang.Numbers.divide (Numbers.java:158)
user=> (assert false)
AssertionError Assert failed: false user/eval1152 (form-init3466436612016038338.clj:1)
Hmm... That is where I was confused a little bit. The following is what's on the wiki page:
Evaluation error at clojure.lang.Numbers.divide (Numbers.java:163). __ArithmeticException__ Divide by zero
which does have the Java exception class name in it, which is different from what's in the screenshot you posted on Twitter, which doesn't.
Since these error messages are meant for human beings (instead of machines/tools), I personally think that Java exception class names are irrelevant in all of the categories of errors messages since the only two things I, as a human being, would like to know about an error are:
What is wrong?
Where is it?
So in this case I referenced, the specific error message "Divide by zero" already helps me answer question 1) so I don't see the value of the more generic exception class name (ArithmeticException) in this particular error message.
In general, I would personally prefer not to see anything Java-related (including Java exception class names) in Clojure error messages (the presence of Java-related stuff is, in my opinion, simply a leak of abstraction.) This is especially helpful for Clojure(Script) beginners who don't have any Java background, yet. I know this is difficult to achieve sometimes (e.g., java.lang.Long) and not in the scope of this particular effort but this would, IMHO, be the right direction in terms of improving error messages in general.
Anyway, it's exciting to see the core team responding to community feedback and addressing this particular issue. This is, for me, "the next big thing" in Clojure. Thank you very much!
Oh, I may have a bug in the impl then - for evaluation errors, you should see the Java exception class in the message. Because these will flow out in Java interop and other cases there is often meaningful information in the cause exception class name (like ClassCastException), so the intent is that it will be there.
It is not a goal to remove Java-related stuff from the exception message. Clojure is a hosted language, embraces the host, and does not try to hide that fact. (It is a goal to remove stuff that's not useful, which may be either Java stuff or Clojure stuff.)
Thank you for the explanation. I totally overlooked the cases where java.lang.Throwable.getMessage may return null and exception class names would be the only meaningful things in those cases.
2
u/final_fantasia Aug 11 '18 edited Aug 11 '18
Here are the equivalent error messages in Clojure 1.8. I'm glad to see Java exception class names removed from error messages.