cucumber / cucumber-expressions

Human friendly alternative to Regular Expressions
MIT License
143 stars 49 forks source link

Verbose alternation-in-optional error message #260

Closed kieran-ryan closed 6 months ago

kieran-ryan commented 7 months ago

🤔 What's changed?

Updated error message for an alternation inside an optional from...

An alternation can not be used inside an optional
You can use '\\/' to escape the '/'

...to...

An alternation can not be used inside an optional
If you did not mean to use an alternation you can use '\\/' to escape the '/'. Otherwise rephrase your expression or consider using a regular expression instead.

⚡️ What's your motivation?

  1. Improve error message consistency
    • Was You can use '\\/' to escape the '/'; while AlternativeMayNotBeEmpty message for similar is If you did not mean to use an alternative you can use '\\/' to escape the '/'
  2. Improve clarity on how to fix if user intention was indeed to use an alternation and an optional. With d(a/o), fixes would be:
    • d(a\/o) - if wanted d and da/o
    • d/da/do, d(a)/do or d(a)/d(o) - if wanted d, da and do
    • or to perhaps use a regular expression

Allows to close cucumber/vscode#142 by improving clarity that message is expected behaviour - so is not re-raised.

🏷️ What kind of change is this?

♻️ Anything particular you want feedback on?

Whether Otherwise rephrase your expression or consider using a regular expression instead. portion is clear or can be improved.

📋 Checklist: