Skip to content

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

@sGy1980de

Description

@sGy1980de

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy