private function validateReturnCode(\GearmanClient $client, string $channel): void
    {
        switch ($client->returnCode()) {
            case GEARMAN_SUCCESS:
            case GEARMAN_WORK_DATA:
            case GEARMAN_WORK_STATUS:
                return;

            case GEARMAN_TIMEOUT:
                throw new \GearmanException(
                    sprintf(
                        'Code [%s] :: Timeout reached, no available workers for channel [%s].',
                        $client->returnCode(),
                        $channel
                    ), $client->returnCode()
                );

            case GEARMAN_ERRNO:
                throw new \GearmanException(
                    sprintf(
                        'Code [%s] :: Error [%s::%s] on channel [%s].',
                        $client->returnCode(),
                        $client->getErrno(),
                        $client->error(),
                        $channel
                    ), $client->returnCode()
                );

            case GEARMAN_WORK_FAIL:
                throw new \GearmanException(
                    sprintf(
                        'Code [%s] :: Worker failed [%s::%s] on channel [%s].',
                        $client->returnCode(),
                        $client->getErrno(),
                        $client->error(),
                        $channel
                    ), $client->returnCode()
                );

            case GEARMAN_LOST_CONNECTION:
            case GEARMAN_COULD_NOT_CONNECT:
                throw new \GearmanException(
                    sprintf(
                        'Code [%s] :: Lost connection to channel [%s].',
                        $client->returnCode(),
                        $channel
                    ), $client->returnCode()
                );

            default:
                throw new \GearmanException(
                    sprintf(
                        'Code [%s] :: Unspecified error [%s::%s] on channel [%s].',
                        $client->returnCode(),
                        $client->getErrno(),
                        $client->error(),
                        $channel
                    ), $client->returnCode()
                );
        }
    }