Transforming parsing errors #116
randomeizer
started this conversation in
Ideas
Replies: 1 comment
-
Ah sorry, I've PR #135 without seeing this discussion. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So, I've been building out my parser here, and have found it useful to have a way of transforming possible errors from a parsing block into something specific to that context. For example, something like this:
This doesn't give a particularly illuminating error message. So I cooked up a
Require
parser, which you use like so:Now at least it will give an idea of what it might be. The message could be more specific as well if desired (
LintError
is just temporary untilParsingError
is public).Currently, the closure gets passed the error that came from the upstream
Parser
, along with theInput
in whatever state the failed parser left it.Not sure this is quite the right shape for it. Another possibility would be a
Parser
extension, something along the lines of:Which would then let you do this instead:
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions