Run the failure callbacks.

Failure callbacks are passed the task object job that failed

@see \MHlavac\Gearman\Task::attachCallback()
179655
public function fail()
    {
        $this->finished = true;
        if (!count($this->callback[self::TASK_FAIL])) {
            return;
        }

        foreach ($this->callback[self::TASK_FAIL] as $callback) {
            call_user_func($callback, $this);
        }
    }
1100209
function onFailure(/*callable*/$callable)
    {
        if ($callable === null) {
            $this->failure = $callable;
            return $this;
        }

        if (!is_callable($callable))
            throw new \Exception(sprintf(
                'The argument given is not callable; given: (%s).'
                , \Poirot\Std\flatten($callable)
            ));

        
        $this->failure = $callable;
        return $this;
    }
1234592
public function fail($exception)
    {
        Event::trigger('onFailure', array(
            'exception' => $exception,
            'job' => $this,
        ));

        $this->updateStatus(Status::STATUS_FAILED);
        Failure::create(
            $this->payload,
            $exception,
            $this->worker,
            $this->queue
        );

        Stat::incr('failed');
        Stat::incr('failed:' . $this->worker);
    }
813568
public function attachCallback($callback, $type = self::JOB_COMPLETE)
    {
        if (!is_callable($callback)) {
            throw new Exception('Invalid callback specified');
        }
        if (!isset($this->callback[$type])) {
            throw new Exception('Invalid callback type specified.');
        }
        $this->callback[$type][] = $callback;
    }
1059986
protected function raiseFailedJobEvent( Job $job )
	{
		$data = json_decode( $job->getRawBody(), true );

		Hooks::trigger( 'queue.job.failed', compact( 'job', 'data' ) );
	}
1180224
public function fail($exception)
	{
		Resque_Event::trigger('onFailure', array(
			'exception' => $exception,
			'job' => $this,
		));

		$this->updateStatus(Resque_Job_Status::STATUS_FAILED);
		Resque_Failure::create(
			$this->payload,
			$exception,
			$this->worker,
			$this->queue
		);
		Resque_Stat::incr('failed');
		Resque_Stat::incr('failed:' . $this->worker);
	}
230897
public function run($callback)
    {
        $attempt = 0;
        $try = true;

        while ($try) {

            $result = null;
            $exception = null;

            $this->wait($attempt);
            try {
                $result = call_user_func($callback);
            } catch (Exception $e) {
                $this->exceptions[] = $e;
                $exception = $e;
            }
            $try = call_user_func($this->decider, ++$attempt, $this->getMaxAttempts(), $result, $exception);

            if($try && isset($this->errorHandler)) {
                call_user_func($this->errorHandler, $exception, $attempt, $this->getMaxAttempts());
            }
        }

        return $result;
    }
995025
public function assignExceptionCallback(GearmanTask $gearmanTask)
    {
        $event = new GearmanClientCallbackExceptionEvent($gearmanTask);
        $this->eventDispatcher->dispatch(
            GearmanEvents::GEARMAN_CLIENT_CALLBACK_EXCEPTION,
            $event
        );
    }
1128317
protected function runJob() {
        if (isset($this->callbackChildren[$this->uid])) {
            $callback = $this->callbackChildren[$this->uid];
            $result = $callback->call($this->callbackParamChildren[$this->uid]);
        } else if ($this->callback) {
            $result = $this->callback->call($this->callbackParam);
        } else {
            $result = null; // no job
        }
        if ($this->getShareResult()) {
            $this->getStorage()->write($this->uid, $result);
        }
        posix_kill($this->pid, 9);
    }
1374261
public function attach(callable $stage, callable $fallback = null)
    {
        $this->storage->attach(
            $this->marshalClosure($stage),
            [
                'fallback' => is_callable($fallback) ? $this->marshalClosure($fallback) : null
            ]
        );
    }
1348506
public function fail($exception = null)
    {
        if ($this->job) {
            FailingJob::handle($this->job->getConnectionName(), $this->job, $exception);
        }
    }
189843
private function insertData($callback = null): void
    {
        $this->expression->evaluateExpressions(
            $this->configEntities[$this->entity]['pre_actions']
        );

        for ($rowNum = 1; $rowNum <= $this->limit; $rowNum++) {
            // Call the right method according to the mode
            $this->{$this->insertMode[$this->mode]}($rowNum);

            if (!is_null($callback)) {
                $callback($rowNum);
            }
        }

        // Run a final method if defined
        if ($this->mode === 'batch') {
            $this->loadDataInBatch('insert');
        }

        $this->expression->evaluateExpressions(
            $this->configEntities[$this->entity]['post_actions']
        );
    }
123184
public function attach($event, $callback) {
        $events = is_array($event) ? $event : array($event);
        $listeners = $this->getOption(self::OPTION_LISTENERS);
        foreach ($events as $event) {
            $eventObject = is_object($event) ? $event : new GenericEvent($event);
            if (!isset($listeners[$eventObject->getName()])) {
                $listeners[$eventObject->getName()] = array();
            }

            if (!in_array($callback, $listeners[$eventObject->getName()], true)) {
                $listeners[$eventObject->getName()][] = $callback;
            }
        }
        $this->setOption(self::OPTION_LISTENERS, $listeners);
    }
785165
protected static function runCallback($callback, $args)
    {
        if (!is_array($args)) {
            $args = isset($args) ? array($args) : array();
        }
        return call_user_func_array($callback, $args);
    }
147289
protected function callAfterDispatchCallbacks()
    {
        try {
            foreach ($this->after_filter_callbacks as $callback) {
                if (is_callable($callback)) {
                    if (is_string($callback)) {
                        $callback($this);

                    } else {
                        call_user_func($callback, $this);

                    }
                }
            }
        } catch (Throwable $e) { // PHP 7 compatibility
            $this->error($e);
        } catch (Exception $e) { // TODO: Remove this catch block once PHP 5.x support is no longer necessary.
            $this->error($e);
        }
    }
476082
protected function raiseFailedJobEvent(Job $job)
	{
		$data = json_decode($job->getRawBody(), true);

		if($this->container->bound('events'))
		{
			$this->container['events']->fire('illuminate.queue.failed', array('sync', $job, $data));
		}
	}
295272
public function run(Task $task, Closure $callback = null)
    {
        $processes = [];

        $callback = $callback ?: function () {
        };

        // Here we will gather all the process instances by host. We will build them in
        // an array so we can easily loop through them then start them up. We'll key
        // the array by the target name and set the value as the process instance.
        foreach ($task->hosts as $host) {
            $process = $this->getProcess($host, $task);

            $processes[$process[0]] = $process[1];
        }

        // Next we'll loop through the processes and run them sequentially while taking
        // the output and feeding it through the callback. This will in turn display
        // the output back out to the screen for the developer to inspect closely.
        foreach ($processes as $host => $process) {
            $process->run(function ($type, $output) use ($host, $callback) {
                $callback($type, $host, $output);
            });
        }

        return $this->gatherExitCodes($processes);
    }