Skip to content

Wrong usage of ServerException #650

Closed
@jeff1985

Description

@jeff1985

During testing of #648 configuration, I got an different issue with the usage of ServerException.

I.e. in enqueue/redis/RedisProducer.php:70 you have the following code:

catch (PRedisServerException $e) {
        throw new ServerException('lpush command has failed', null, $e);
    }

In case of an exception I'm getting:

[Symfony\Component\Debug\Exception\FatalThrowableError]
Wrong parameters for Enqueue\Redis\ServerException([string $message [, long $code [, 
Throwable $previous = NULL]]])

Which is because of the null parameter. ServerException is a subclass of \Exception and the __construct() is defined as:
(see http://php.net/manual/de/class.exception.php )

public __construct ([ string $message = "" [, int $code = 0 [, Throwable $previous = NULL ]]] )

null is not int, so you'll need to pass 0 in your exception calls.

For reference:

$ php -v 
PHP 7.1.19-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jul  9 2018 13:12:24) ( NTS )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions