You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parsers.Parser don't provide an easy way to override error messages. The common idiom for that is unsuspectingly very fragile. I suggest adding two new method, withFailureMessage and withErrorMessage, to provide that functionality. As for the problem, I'll let the comment in my proposed API describe it:
The semantics are slightly different than those obtained by doing | failure(msg), in that the message produced by this method will always replace the message produced, which is not guaranteed by that idiom.
For example, parser p below will always produce the designated failure message, while q will not produce it if sign is parsed but number is not.
defp= sign.?~ number withFailureMessage "Number expected!"defq= sign.?~ number | failure("Number expected!")
The text was updated successfully, but these errors were encountered:
Parsers.Parser don't provide an easy way to override error messages. The common idiom for that is unsuspectingly very fragile. I suggest adding two new method,
withFailureMessage
andwithErrorMessage
, to provide that functionality. As for the problem, I'll let the comment in my proposed API describe it:The semantics are slightly different than those obtained by doing
| failure(msg)
, in that the message produced by this method will always replace the message produced, which is not guaranteed by that idiom.For example, parser
p
below will always produce the designated failure message, whileq
will not produce it ifsign
is parsed butnumber
is not.The text was updated successfully, but these errors were encountered: