greglook / cljstyle

A tool for formatting Clojure code
Eclipse Public License 1.0
293 stars 39 forks source link

Better processing error reporting #29

Closed greglook closed 4 years ago

greglook commented 4 years ago

When the formatting functions in cljstyle encounter a form they can't process, the error is some arbitrary exception like NullPointerException or ClassCastException which bubbles up from deep within the code. This means that the end user doesn't get any feedback about what form caused the error - the granularity is only on the file level.

An improvement would be to have an intermediate layer in transform or somewhere equivalent that would catch these errors and re-throw a wrapped exception which contained information about the location in the file (using rewrite-clj's custom zipper) as well as a string with a tightly-scoped form that reproduces the error. Minimally, you could zip up to the enclosing top-level form and report that in the error.

greglook commented 4 years ago

Done in e25b261.