reasonml-old / BetterErrors

Make OCaml/Reason errors prettier
MIT License
124 stars 14 forks source link

Output errors in json format #13

Open rgrinberg opened 8 years ago

rgrinberg commented 8 years ago

I was looking for something like this but instead of pretty printing the errors, it would be nice if they could be outputted into json, e.g. using some --json flag. This will allow me to write tools on top of ocaml-better-errors.

Do you think this feature would fit with the tool?

jordwalke commented 8 years ago

@rgrinberg: I think that makes sense if the canonical data structures are OCaml data types, but then could be serialized to JSON using one of the popular OCaml -> JSON serializers. It would be cool if the data types in this repo would resemble (or even use) the compiler-libs error data types so perhaps upstream OCaml would allow custom error plugins that can be injected and print those data types in arbitrary ways (and then this library would "just work"). Thoughts?

chenglou commented 8 years ago

Outputting to whatever actual data structure is very intentional. The code is divided between main.ml, the parser that turns things into the data structure, and the decoupled reporter, my own (subjectively) nicer output of the ocaml messages.

I haven't had the change to polish the readme, as I didn't think people would notice this. I'll freshening it up one day. Sorry for the trouble!