diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dc142b75..73ea9069a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Changed - [Ruby] Added subsidiary rubocop gems (RSpec/Rake/Performance), and did some initial refactoring ([#247](https://github.com/cucumber/cucumber-expressions/pull/247)) +- Additional information for alternation inside optional error message on how to fix ([#260](https://github.com/cucumber/cucumber-expressions/pull/260)) ### Fixed - Removed repeated 'the' from error message for use of alternations inside optionals ([#252](https://github.com/cucumber/cucumber-expressions/issues/252)) diff --git a/dotnet/CucumberExpressions/CucumberExpressionException.cs b/dotnet/CucumberExpressions/CucumberExpressionException.cs index 810d75054..f0a5efd9d 100644 --- a/dotnet/CucumberExpressions/CucumberExpressionException.cs +++ b/dotnet/CucumberExpressions/CucumberExpressionException.cs @@ -30,7 +30,7 @@ internal static CucumberExpressionException CreateAlternationNotAllowedInOptiona expression, PointAt(current), "An alternation can not be used inside an optional", - "You can use '\\/' to escape the '/'" + "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." )); } diff --git a/go/errors.go b/go/errors.go index e59270e30..6ff615b61 100644 --- a/go/errors.go +++ b/go/errors.go @@ -34,7 +34,7 @@ func createAlternationNotAllowedInOptional(expression string, current token) err expression, pointAtToken(current), "An alternation can not be used inside an optional", - "You can use '\\/' to escape the '/'", + "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.", )) } diff --git a/java/src/main/java/io/cucumber/cucumberexpressions/CucumberExpressionException.java b/java/src/main/java/io/cucumber/cucumberexpressions/CucumberExpressionException.java index 447d8458b..0dd23f1cd 100644 --- a/java/src/main/java/io/cucumber/cucumberexpressions/CucumberExpressionException.java +++ b/java/src/main/java/io/cucumber/cucumberexpressions/CucumberExpressionException.java @@ -34,7 +34,7 @@ static CucumberExpressionException createAlternationNotAllowedInOptional(String expression, pointAt(current), "An alternation can not be used inside an optional", - "You can use '\\/' to escape the '/'" + "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." )); } diff --git a/javascript/src/Errors.ts b/javascript/src/Errors.ts index ae542dc86..3bef9173b 100644 --- a/javascript/src/Errors.ts +++ b/javascript/src/Errors.ts @@ -115,7 +115,7 @@ export function createAlternationNotAllowedInOptional(expression: string, curren expression, pointAtLocated(current), 'An alternation can not be used inside an optional', - "You can use '\\/' to escape the '/'" + "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." ) ) } diff --git a/python/cucumber_expressions/errors.py b/python/cucumber_expressions/errors.py index 1ef16af7b..151e73e06 100644 --- a/python/cucumber_expressions/errors.py +++ b/python/cucumber_expressions/errors.py @@ -140,7 +140,10 @@ def __init__(self, expression: str, current): expression=expression, pointer=point_at_located(current), problem="An alternation can not be used inside an optional", - solution="You can use '\\/' to escape the '/'", + solution=( + "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." + ), ) ) diff --git a/ruby/lib/cucumber/cucumber_expressions/errors.rb b/ruby/lib/cucumber/cucumber_expressions/errors.rb index 5db9e3909..96884d116 100644 --- a/ruby/lib/cucumber/cucumber_expressions/errors.rb +++ b/ruby/lib/cucumber/cucumber_expressions/errors.rb @@ -158,7 +158,7 @@ def initialize(expression, current) expression, point_at_located(current), 'An alternation can not be used inside an optional', - "You can use '\\/' to escape the '/'" + "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." ) ) end diff --git a/testdata/cucumber-expression/matching/does-not-allow-alternation-in-optional.yaml b/testdata/cucumber-expression/matching/does-not-allow-alternation-in-optional.yaml index b2ee38201..f15f8af9f 100644 --- a/testdata/cucumber-expression/matching/does-not-allow-alternation-in-optional.yaml +++ b/testdata/cucumber-expression/matching/does-not-allow-alternation-in-optional.yaml @@ -7,4 +7,4 @@ exception: |- three( brown/black) mice ^ An alternation can not be used inside an optional. - You can use '\/' to escape the '/' + 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.