Closed
Description
Description
Currently if anyone will try to catch WrappedExceptionsInterface
, he will receive following psalm static analysis error:
ERROR: InvalidCatch
at /home/rela589n/Projects/opensource/phphd/exceptional-validation-bundle/Messenger/ExceptionalValidationMiddleware.php:31:9
Class/interface Symfony\Component\Messenger\Exception\WrappedExceptionsInterface cannot be caught (see https://psalm.dev/132)
try {
return $stack->next()->handle($envelope, $stack);
} catch (WrappedExceptionsInterface $exception) {
/** @var WrappedExceptionsInterface&Throwable $exception */
$thrownException = new MessengerThrownException($exception);
It would make sense to make all exception interfaces extend Throwable
in order to avoid this issue:
-interface WrappedExceptionsInterface
+interface WrappedExceptionsInterface extends \Throwable
{
/**
* @return \Throwable[]
*/
public function getWrappedExceptions(?string $class = null, bool $recursive = false): array;
}
It's a minor enhancement, but it would still improve DX when working with Symfony
Example
No response