master

laravel/framework

Last updated at: 29/12/2023 09:23

PendingClosureDispatch.php

TLDR

This file defines the PendingClosureDispatch class, which extends the PendingDispatch class. It contains a single method named catch that adds a callback to be executed if the job fails.

Methods

catch

This method takes a closure as a parameter and adds the closure as a failure callback for the job. It returns the current instance of the PendingClosureDispatch class.

<?php

namespace Illuminate\Foundation\Bus;

use Closure;

class PendingClosureDispatch extends PendingDispatch
{
    /**
     * Add a callback to be executed if the job fails.
     *
     * @param  \Closure  $callback
     * @return $this
     */
    public function catch(Closure $callback)
    {
        $this->job->onFailure($callback);

        return $this;
    }
}