diff --git a/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php b/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php index 7bb16b56..988e9ee2 100644 --- a/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php +++ b/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php @@ -27,9 +27,13 @@ protected function feedParserWithNodes(Parser $parser): void { $lexer = $parser->getLexer(); - $this->nodes[] = $parser->{$this->commonNodeMapping}(); - if ($lexer->lookahead?->type === null) { - throw ParserException::missingLookaheadType(); + try { + $this->nodes[] = $parser->{$this->commonNodeMapping}(); + if ($lexer->lookahead?->type === null) { + throw ParserException::missingLookaheadType(); + } + } catch (\Throwable $throwable) { + throw ParserException::withThrowable($throwable); } $aheadType = $lexer->lookahead->type; diff --git a/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Exception/ParserException.php b/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Exception/ParserException.php index 5b4ff1d8..a6aa576f 100644 --- a/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Exception/ParserException.php +++ b/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Exception/ParserException.php @@ -10,4 +10,9 @@ public static function missingLookaheadType(): self { return new self("The parser's 'lookahead' property is not populated with a type"); } + + public static function withThrowable(\Throwable $throwable): self + { + return new self($throwable->getMessage(), $throwable->getCode(), $throwable); + } }