Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpKernel] HttpException does not allow \Error as $previous argument #30728

Copy link
Copy link
Closed
@sGy1980de

Description

@sGy1980de
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.