Skip to content

Commit

Permalink
Verbose alternation in optional error message (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
kieran-ryan authored Dec 30, 2023
1 parent f788a89 commit d623c9a
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion dotnet/CucumberExpressions/CucumberExpressionException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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."
));
}

Expand Down
2 changes: 1 addition & 1 deletion go/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
));
}

Expand Down
2 changes: 1 addition & 1 deletion javascript/src/Errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
)
}
Expand Down
5 changes: 4 additions & 1 deletion python/cucumber_expressions/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
),
)
)

Expand Down
2 changes: 1 addition & 1 deletion ruby/lib/cucumber/cucumber_expressions/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit d623c9a

Please sign in to comment.