This repository was archived by the owner on Apr 2, 2026. It is now read-only.
Way to quickly throw an error? #969
Unanswered
BinaryQuantumSoul
asked this question in
Q&A
Replies: 1 comment 3 replies
-
|
Could you elaborate on the use case? Your first example for throwing an error is a Parser which is currently infallible. If I understand correctly that you are trying to parse a disallowed pattern (such as in Rust It really depends on what your parse tree supports, and what you are actually wanting to do. Do you want to stop parsing the first time you see a bad pattern or do you want to just error and keep going? Does your parse tree support |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Right now the only usable way I've found to throw errors in specific pattern mistakes is using:
when something is unterminated
or
when something is forbidden. The to(None) os to reuse same format as prior.
But this is quite a lot of boilerplate and it also forces to convert MyError to String (I don't kow why Rich::custom forces strings, but implementing my own error type for this seems like huge work with a lot of duplication) and parse it back from string after parsing.
Is there a better way?
map_errseems even more cumbersome.Beta Was this translation helpful? Give feedback.
All reactions