Skip to content

Commit

Permalink
Cast table node exceptions into ParserExceptions when throwing
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranmcnulty committed Feb 5, 2021
1 parent 2391482 commit 67bc894
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Behat/Gherkin/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -565,7 +566,17 @@ protected function parseExamples()
*/
protected function parseTable()
{
return new TableNode($this->parseTableRows());
try {
return new TableNode($this->parseTableRows());
}
catch(NodeException $e) {
throw new ParserException(
$e->getMessage() . $this->file ? ' in file '.$this->file : '',
0,
null,
$e
);
}
}

/**
Expand Down

0 comments on commit 67bc894

Please sign in to comment.