Feature: error printer #86
Labels
A-misc
Area: Issues that don't fint into specific category
C-feature-request
Category: A feature request, i.e. not implemented
What do you think about including a
formatError
function?I wrote a function that takes the input string and a
Failure
instance, and prints out the surrounding +/- n lines with line-numbers etc.I don't know if it's wise to include this in the library, since parser errors aren't the only type of errors you'd want to print - though, on the other hand, if the function was just something like
formatError(input: string, offset: number, expectation: string)
, then this could be used to inject whateverexpectation
you want, to print out semantic errors and so on.Not 100% sure if this is a good idea, as error formats can be quite different in different projects - but on the other hand, it might be nice to have something you can use just to get your project started and get something useful on the screen without doing a lot of ground work?
Up to you, but I do have something I could PR, if you'd like. 🙂
The text was updated successfully, but these errors were encountered: