-
Notifications
You must be signed in to change notification settings - Fork 94
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
Cast table node exceptions into ParserExceptions when throwing #216
Changes from 1 commit
6f7a557
9373a13
363dd69
a79bb0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
namespace Behat\Gherkin; | ||
|
||
use Behat\Gherkin\Exception\LexerException; | ||
use Behat\Gherkin\Exception\NodeException; | ||
use Behat\Gherkin\Exception\ParserException; | ||
use Behat\Gherkin\Node\BackgroundNode; | ||
use Behat\Gherkin\Node\ExampleTableNode; | ||
|
@@ -565,7 +566,16 @@ protected function parseExamples() | |
*/ | ||
protected function parseTable() | ||
{ | ||
return new TableNode($this->parseTableRows()); | ||
try { | ||
return new TableNode($this->parseTableRows()); | ||
} | ||
catch(NodeException $e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be on the previous line to follow PSR-2/PSR-12 |
||
throw new ParserException( | ||
$e->getMessage() . $this->file ? ' in file '.$this->file : '', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are missing braces around the ternary. The current code is executed as |
||
0, | ||
$e | ||
); | ||
} | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably keep the
parseTableRows
outside thetry/catch
so that we catch only the exceptions fromTableNode
.