src/Jobs/BaseJob.php
public function fail(string $group, string $message)
    {
        if ($this->completed || $this->failed) {
            throw new JobAlreadyFinishedException();
        }

        $jsonData = json_encode($this->data, JSON_UNESCAPED_SLASHES) ?: '{}';

        $this->getEventsManager()->fire(new JobEvent\OnFailure($this, $this, $group, $message));

        $this->failed = true;

        return $this->client->fail($this->jid, $this->worker, $group, $message, $jsonData);
    }
public function fail(string $group, string $message)
    {
        if ($this->completed || $this->failed) {
            throw new JobAlreadyFinishedException();
        }

        $jsonData = json_encode($this->data, JSON_UNESCAPED_SLASHES) ?: '{}';

        $this->getEventsManager()->fire(new JobEvent\OnFailure($this, $this, $group, $message));

        $this->failed = true;

        return $this->client->fail($this->jid, $this->worker, $group, $message, $jsonData);
    }
Mark the current Job as failed, with the provided group, and a more specific message.

@param string $group   Some phrase that might be one of several categorical modes of failure
@param string $message Something more job-specific, like perhaps a traceback.

@return bool|string The id of the failed Job if successful, or FALSE on failure.