-
Notifications
You must be signed in to change notification settings - Fork 4
Feature: error printer #86
Copy link
Copy link
Open
Labels
A-miscArea: Issues that don't fint into specific categoryArea: Issues that don't fint into specific categoryC-feature-requestCategory: A feature request, i.e. not implementedCategory: A feature request, i.e. not implemented
Description
Metadata
Metadata
Assignees
Labels
A-miscArea: Issues that don't fint into specific categoryArea: Issues that don't fint into specific categoryC-feature-requestCategory: A feature request, i.e. not implementedCategory: A feature request, i.e. not implemented
What do you think about including a
formatErrorfunction?I wrote a function that takes the input string and a
Failureinstance, 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 whateverexpectationyou 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. 🙂