-
Notifications
You must be signed in to change notification settings - Fork 92
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
Conversation
67bc894
to
6f7a557
Compare
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.
We probably need the same try/catch in parseExamples
when instantiating the ExampleTableNode
src/Behat/Gherkin/Parser.php
Outdated
try { | ||
return new TableNode($this->parseTableRows()); | ||
} | ||
catch(NodeException $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.
should be on the previous line to follow PSR-2/PSR-12
src/Behat/Gherkin/Parser.php
Outdated
} | ||
catch(NodeException $e) { | ||
throw new ParserException( | ||
$e->getMessage() . $this->file ? ' in file '.$this->file : '', |
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.
you are missing braces around the ternary. The current code is executed as ($e->getMessage() . $this->file) ? ' in file '.$this->file : ''
which is not what you want.
src/Behat/Gherkin/Parser.php
Outdated
@@ -565,7 +566,16 @@ protected function parseExamples() | |||
*/ | |||
protected function parseTable() | |||
{ | |||
return new TableNode($this->parseTableRows()); | |||
try { | |||
return new TableNode($this->parseTableRows()); |
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 the try/catch
so that we catch only the exceptions from TableNode
.
bc94163
to
a79bb0a
Compare
Rather than leaking this, we should make a ParserException
Closes #212