bhb / expound

Human-optimized error messages for clojure.spec
Eclipse Public License 1.0
924 stars 24 forks source link

optional include location of the spec error in the message. #241

Open drewverlee opened 2 years ago

drewverlee commented 2 years ago

When i'm reading expound formatted spec errors it's usually very clear what the issue is, it's not immediately clear where the error is. This information: the filename, and possible the row and column. Is in the raw spec error output as well as the SO, but they can be far from the expound message. In the case of the raw spec error, is just a big clojure map that's tiresome to parse.

My suggestion is to either always include that information nearby so it's easy to find. Maybe something like:

-- Spec failed --------------------

  1

should satisfy

  string?

Found in foo.main:67:3:2
-------------------------

I'm not really sure what the UI should be exactly. maybe even in the header like:

-- Spec failed at foo.main:67:3:2 --------------------

bhb commented 2 years ago

@drewverlee Thanks for the idea! I'll look into it.

bhb commented 1 year ago

@drewverlee Sorry for the delay here! I've had a bunch of other stuff going on.

This is a cool idea, but AFAICT, the data that is passed to expound (the result of s/explain-data) doesn't appear to include this line number information.

I may be missing something, though! Can you provide more context on your setup e.g. when expound is invoked?