Improving error messages from OneOf
#124
Replies: 3 comments 4 replies
-
This is not for all uses of ' |
Beta Was this translation helpful? Give feedback.
-
Any thoughts on this @stephencelis / @mbrandonw? |
Beta Was this translation helpful? Give feedback.
-
@randomeizer Thanks for starting the discussion! We were busy prepping the release so haven't had a chance to catch up till now 😄 We definitely think this could be improved with the internal
We'll hopefully explore this soon! If you end up messing around with things, be warned that it's probably the messiest part of the code base 😅 |
Beta Was this translation helpful? Give feedback.
-
So, I've been using the throwing version of the library here. I have a
OneOf
which contains about 7 different possible sub-parsers. When all of them fail, you end up with a lot of error messages.A thought I had for improving that would be for the 'many error' aggregator to try and pick a winner based on which one progressed furthest through the input before failing. In most cases, the parser which gets furthest is most likely the (eventually) correct one.
If any sub-parsers are equal, they all get aggregated, otherwise just the winner gets passed on.
The progress could come from either the thrown
ParsingError
's record of theInput
, or if it's not aParsingError
, the unconsumed input post-OneOf
. This will be more generally helpful onceParsingError
is made public.Beta Was this translation helpful? Give feedback.
All reactions