Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rethrowing an exception within the catch bloc is not detected when it's done by a method #54

Open
billgsm opened this issue May 8, 2020 · 0 comments

Comments

@billgsm
Copy link

billgsm commented May 8, 2020

try {
// ....
} catch (\Throwable $e) {
     // ....
     \MyProject\Namespace\MyCustomException::raise($id, $e /*will be injected as previous*/)
}

// src/Exception/MyCustomException.php
namespace MyProject\Namespace;

class MyCustomException extends \Exception
{
    public static function raise(string $id, \Throwable $previous)
    {
        throw new self("something went wrong with #{$id}", 0, $previous);
    }
}

This will not be detected and I get this message:

caught "Throwable" must be rethrown. Either catch amore specific exception or add a "throw" clause in the "catch" block to propagate the exception. More info:

Does this rule require the rethrow be explicit or is it just a small bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant