Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verbose alternation-in-optional error message #260

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
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
Expand Up @@ -30,7 +30,7 @@ public CucumberExpressionException(string message, Exception innerException) : b
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
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
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
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
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
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
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.