Closed
Description
Symfony version(s) affected: 4.2.x
Description
HttpException
and all its descendants do not allow \Error
as $previous
argument and raise a TypeError
by itself. This is quite weird, as those cases have to be handled separately and cannot be handled with a generic \Throwable
catch block.
❓ I could imagine this has been forgotten in the PHP 7.x
transition?
How to reproduce
try {
throw new class ("arbitrary error") extends \Error {};
} catch (\Throwable $err) {
throw new \Symfony\Component\HttpKernel\Exception\HttpException(500, 'An unsuspected error occurred.', $err);
}
Possible Solution
Change signature of HttpException
to hint \Throwable
instead of \Exception
for $previous
as defined in \Exception
.