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

Cast table node exceptions into ParserExceptions when throwing #216

Merged
merged 4 commits into from
Feb 17, 2021

Conversation

ciaranmcnulty
Copy link
Contributor

Rather than leaking this, we should make a ParserException

Closes #212

Copy link
Member

@stof stof left a 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

try {
return new TableNode($this->parseTableRows());
}
catch(NodeException $e) {
Copy link
Member

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

}
catch(NodeException $e) {
throw new ParserException(
$e->getMessage() . $this->file ? ' in file '.$this->file : '',
Copy link
Member

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.

@@ -565,7 +566,16 @@ protected function parseExamples()
*/
protected function parseTable()
{
return new TableNode($this->parseTableRows());
try {
return new TableNode($this->parseTableRows());
Copy link
Member

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.

@ciaranmcnulty ciaranmcnulty merged commit ee41d3a into Behat:master Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent cells count throws low-level error
2 participants