[CLJ-1099] better error message when passing non-seq to seq Created: 01/Nov/12 Updated: 24/May/13 Resolved: 24/May/13 |
|
| Status: | Closed |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | Release 1.6 |
| Type: | Enhancement | Priority: | Minor |
| Reporter: | Stuart Halloway | Assignee: | Unassigned |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Patch: | Code |
| Approval: | Ok |
| Description |
|
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: (cons 1 2) => IllegalArgumentException Don't know how to create ISeq from: java.lang.Long Error message after: user=> (cons 1 2)
ExceptionInfo Don't know how to create ISeq from: java.lang.Long
user=> (ex-data *e)
{:instance 2}
|
| Comments |
| 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 ] |
|
Hi Michael, 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. |