From 84d7c4eec6771f8504de67b33d6dd6545fa38bf7 Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Fri, 14 Mar 2025 01:57:18 +0000 Subject: [PATCH] fix: wrap up ORM v3 throwable when parsing fails in variadic functions --- .../ORM/Query/AST/Functions/BaseVariadicFunction.php | 10 +++++++--- .../Query/AST/Functions/Exception/ParserException.php | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) 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); + } }