Skip to end of metadata
Go to start of metadata

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.

Idea 1: Error information is data, and type-based error handling should be discouraged. So prefer the ExceptionInfo class for reporting all errors.

Idea 2: Error behavior is typically unspecified, or minimally specified, in Clojure. This is deliberate, and the tests should reflect this. (Tests are not docs. Docs are docs. Duh.) Check for Throwable, not something more specific.

Idea 3: Notwithstanding #2, people are likely to consume exceptions programmatically, once they are available as data. Even though we aren't promising the shape of this exception data, we should think carefully about names, and envision the possibility of promising more in the future. In this patch I have used :instance as a key to point to an offending instance, which IMO has the potential to be a good generic name in a variety of settings.

Idea 4: ExceptionInfo should not serialize data into the error message string. This is a can of worms: What if the data is big? What if serializing the data itself causes further errors? What if the data is lazy? Putting the data in the map lets the consumer face all these problems as they choose, instead of having to configure the error mechanism to face them.

Idea 5: People (and tools) may not be accustomed to looking in the map (i.e. calling ex-data) to get details about problems. Downstream tools that process exceptions may need to be enhanced to take advantage of ExceptionInfo.