Add span information to errors

Resolves #432.

@garyb @joneshf @ExternalReality Could you please review?

I tried to keep the format of the old error messages as much as possible, so that things like purscheck should continue to work.