Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: error printer #86

Open
mindplay-dk opened this issue Aug 12, 2023 · 0 comments
Open

Feature: error printer #86

mindplay-dk opened this issue Aug 12, 2023 · 0 comments
Assignees
Labels
A-misc Area: Issues that don't fint into specific category C-feature-request Category: A feature request, i.e. not implemented

Comments

@mindplay-dk
Copy link
Contributor

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 whatever expectation 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. 🙂

@norskeld norskeld self-assigned this Aug 12, 2023
@norskeld norskeld added A-misc Area: Issues that don't fint into specific category C-feature-request Category: A feature request, i.e. not implemented labels Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-misc Area: Issues that don't fint into specific category C-feature-request Category: A feature request, i.e. not implemented
Projects
None yet
Development

No branches or pull requests

2 participants