Skip to content

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

Open
@billgsm

Description

@billgsm
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions