Skip to content

Commit 8cef119

Browse files
committed
Avoiding double-wrapping of Twig RuntimeError
1 parent 998c287 commit 8cef119

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/TwigComponent/src/Twig/ComponentExtension.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,15 @@ public function finishEmbeddedComponentRender(): void
8787

8888
private function throwRuntimeError(string $name, \Throwable $e): void
8989
{
90+
// if it's already a Twig RuntimeError, just rethrow it
91+
if ($e instanceof RuntimeError) {
92+
throw $e;
93+
}
94+
9095
if (!($e instanceof \Exception)) {
9196
$e = new \Exception($e->getMessage(), $e->getCode(), $e->getPrevious());
9297
}
98+
9399
throw new RuntimeError(sprintf('Error rendering "%s" component: %s', $name, $e->getMessage()), previous: $e);
94100
}
95101
}

0 commit comments

Comments
 (0)