Skip to content

Commit

Permalink
bug #2030 Fix: Original Throwable get lost during component render (c…
Browse files Browse the repository at this point in the history
…uchac)

This PR was squashed before being merged into the 2.x branch.

Discussion
----------

Fix: Original Throwable get lost during component render

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| Issues        |
| License       | MIT

When non-Exception Throwable is thrown during component rendering, original Throwable is lost together with it's stacktrace. Without stacktrace it is hard to debug the problem. This simple change fixes the problem in the same way as in https://github.com/cuchac/ux/blob/f69b9656f318464253590a6575da65f34262d931/src/TwigComponent/src/Twig/ComponentExtension.php#L127  where `previous: $e` is used instead of  `previous: $e->getPrevious()`

Commits
-------

89552aa Fix: Original Throwable get lost during component render
  • Loading branch information
kbond committed Aug 20, 2024
2 parents 4a80718 + 89552aa commit 70c68d8
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/TwigComponent/src/Twig/ComponentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ private function throwRuntimeError(string $name, \Throwable $e): void
throw $e;
}

if (!($e instanceof \Exception)) {
$e = new \Exception($e->getMessage(), $e->getCode(), $e->getPrevious());
}

throw new RuntimeError(\sprintf('Error rendering "%s" component: %s', $name, $e->getMessage()), previous: $e);
throw new RuntimeError(\sprintf('Error rendering "%s" component: "%s"', $name, $e->getMessage()), previous: $e);
}
}

0 comments on commit 70c68d8

Please # to comment.