Skip to content

Commit d623c9a

Browse files
authored
Verbose alternation in optional error message (#260)
1 parent f788a89 commit d623c9a

File tree

8 files changed

+11
-7
lines changed

8 files changed

+11
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
## [Unreleased]
99
### Changed
1010
- [Ruby] Added subsidiary rubocop gems (RSpec/Rake/Performance), and did some initial refactoring ([#247](https://github.com/cucumber/cucumber-expressions/pull/247))
11+
- Additional information for alternation inside optional error message on how to fix ([#260](https://github.com/cucumber/cucumber-expressions/pull/260))
1112

1213
### Fixed
1314
- Removed repeated 'the' from error message for use of alternations inside optionals ([#252](https://github.com/cucumber/cucumber-expressions/issues/252))

dotnet/CucumberExpressions/CucumberExpressionException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal static CucumberExpressionException CreateAlternationNotAllowedInOptiona
3030
expression,
3131
PointAt(current),
3232
"An alternation can not be used inside an optional",
33-
"You can use '\\/' to escape the '/'"
33+
"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."
3434
));
3535
}
3636

go/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func createAlternationNotAllowedInOptional(expression string, current token) err
3434
expression,
3535
pointAtToken(current),
3636
"An alternation can not be used inside an optional",
37-
"You can use '\\/' to escape the '/'",
37+
"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.",
3838
))
3939
}
4040

java/src/main/java/io/cucumber/cucumberexpressions/CucumberExpressionException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static CucumberExpressionException createAlternationNotAllowedInOptional(String
3434
expression,
3535
pointAt(current),
3636
"An alternation can not be used inside an optional",
37-
"You can use '\\/' to escape the '/'"
37+
"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."
3838
));
3939
}
4040

javascript/src/Errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export function createAlternationNotAllowedInOptional(expression: string, curren
115115
expression,
116116
pointAtLocated(current),
117117
'An alternation can not be used inside an optional',
118-
"You can use '\\/' to escape the '/'"
118+
"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."
119119
)
120120
)
121121
}

python/cucumber_expressions/errors.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ def __init__(self, expression: str, current):
140140
expression=expression,
141141
pointer=point_at_located(current),
142142
problem="An alternation can not be used inside an optional",
143-
solution="You can use '\\/' to escape the '/'",
143+
solution=(
144+
"If you did not mean to use an alternation you can use '\\/' to escape the '/'. "
145+
"Otherwise rephrase your expression or consider using a regular expression instead."
146+
),
144147
)
145148
)
146149

ruby/lib/cucumber/cucumber_expressions/errors.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def initialize(expression, current)
158158
expression,
159159
point_at_located(current),
160160
'An alternation can not be used inside an optional',
161-
"You can use '\\/' to escape the '/'"
161+
"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."
162162
)
163163
)
164164
end

testdata/cucumber-expression/matching/does-not-allow-alternation-in-optional.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ exception: |-
77
three( brown/black) mice
88
^
99
An alternation can not be used inside an optional.
10-
You can use '\/' to escape the '/'
10+
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.

0 commit comments

Comments
 (0)