hylang/hy — pull request #389 by rwtolbert (2013-12-22 20:53:35+00:00)
Title: First pass at some simpler error messages

Instead of letting HyTypeError and LexException just dump a long
traceback, this change adds a dump() method to each than can be
passed the current source, and will print a user friendly error
message with a pointer to the problem in the source.

The error message is colored if clint is installed, but to avoid
yet another dependency, you get monochrome without clint.

I'm sure there is a better way to do the markup, the current method
is kludgy but works.

I wish there was more shared code between HyTypeError and LexException
but they are kind of different in some fundamental ways.

This doesn't work (yet) with runtime errors generated from Python,
like NameError, but I have a method that can catch NameError and turn it
into a more pleasing output.

Finally, there is no obvious way to raise HyTypeError from pure Hy code,
so methods in core/language.hy throw ugly TypeError/ValueError.