Skip to content

Commit 59a8cb9

Browse files
fix: wrap up ORM v3 throwable when parsing fails in variadic functions (#285)
1 parent e36a2c2 commit 59a8cb9

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ protected function feedParserWithNodes(Parser $parser): void
2727
{
2828
$lexer = $parser->getLexer();
2929

30-
$this->nodes[] = $parser->{$this->commonNodeMapping}();
31-
if ($lexer->lookahead?->type === null) {
32-
throw ParserException::missingLookaheadType();
30+
try {
31+
$this->nodes[] = $parser->{$this->commonNodeMapping}();
32+
if ($lexer->lookahead?->type === null) {
33+
throw ParserException::missingLookaheadType();
34+
}
35+
} catch (\Throwable $throwable) {
36+
throw ParserException::withThrowable($throwable);
3337
}
3438

3539
$aheadType = $lexer->lookahead->type;

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Exception/ParserException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ public static function missingLookaheadType(): self
1010
{
1111
return new self("The parser's 'lookahead' property is not populated with a type");
1212
}
13+
14+
public static function withThrowable(\Throwable $throwable): self
15+
{
16+
return new self($throwable->getMessage(), $throwable->getCode(), $throwable);
17+
}
1318
}

0 commit comments

Comments
 (0)