Skip to content

Type issue with exceptions #98

Closed
Closed
@func0der

Description

Hey mate,

I found a type problem in the exception handling.

Your are catching \Throwable here: https://github.com/prolic/HumusAmqp/blob/master/src/Driver/PhpAmqpLib/Queue.php#L193-L195

But AmqpException::fromPhpAmqpLib() can only handle \Exception: https://github.com/prolic/HumusAmqp/blob/master/src/Exception/AmqpException.php#L34

If there was an error like this Call to undefined method PhpAmqpLib\Channel\AMQPChannel::is_consuming() which just occurred in my code, PHP would fataly crash with:

TypeError: Argument 1 passed to Humus\Amqp\Exception\AmqpException::fromPhpAmqpLib() must be an instance of Exception, instance of Error given, called in vendor/prolic/humus-amqp/src/Driver/PhpAmqpLib/Queue.php on line 194 and defined in vendor/prolic/humus-amqp/src/Exception/AmqpException.php:34
Totally unrelated, just an example how I found it.

Such errors are easily spotted with static code analyses like PhpStan oder Psalm. :)

I am of to debug the unrelated problem above.
flys away :D

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions