[CLJ-1099] better error message when passing non-seq to seq Created: 01/Nov/12 Updated: 24/Feb/15
Design discussion here.
This patch improves Clojure's error message for a single common error: passing a non-seq where a seq is neede. More importantly, it is intended as a prototype for other similar improvements in the future.
Error message before:
Error message after:
|Comment by Michael Klishin [ 12/Nov/12 10:34 AM ]|
Wouldn't it be better to make it read "Don't know how to create ISeq from: 2 (java.lang.Long)"? How many beginners will figure
|Comment by Stuart Halloway [ 12/Apr/13 11:36 AM ]|
ex-info messages should not, in general, pr-str things into their bodies. This raises the question of print-length and print-level in a place where the user doesn't have good control, while the whole point of ex-info is to be in the data business, not the string business. Users can control printing from ex-data any way they like.
There are two possible ways to make beginners aware of ex-data: Tell them about it in one (or a few places) in docs, or in an infinite number of places saying "This would have been useful here, but we didn't use it because you might not know about it." I prefer the former.
That said, I think it would be great to increase the visibility of ex-info and ex-data early on in documentation for beginners, and to make sure that things like exception printing in logs are flexible enough not to lose the benefits of ex-info.
|Comment by Andy Fingerhut [ 25/Mar/14 5:14 PM ]|
Just a comment that this fix was committed before release 1.6.0, and then reverted very shortly before release 1.6.0. I believe the reason for reverting was due to concerns that this change made performance about 5% slower in some relatively common cases, with a suspicion that it could have affected inlining of the seqFrom method.
Not sure whether the ticket should be reopened or not.