As I use my Pipelines inside Job classes, I will follow you @hakre kind of.
My Pipeline steps will throw the exceptions which let the job fail and as a result the job "failed" function get called which finally handles the exception ,e.g.:
class GetLabelsV0 implements ShouldQueue
{
use Queueable;
use InteractsWithQueue;
/**
* The number of times the job may be attempted.
*
* @var int
*/
public $tries = 1;
/**
* Indicate if the job should be marked as failed on timeout.
*
* @var bool
*/
public $failOnTimeout = true;
/**
* The number of seconds the job can run before timing out.
*
* @var int
*/
public $timeout = 180;
protected InboundShippingLabelContainer $container;
/**
* Create a new job instance.
*/
public function __construct(InboundShippingLabelContainer $container)
{
$this->container = $container;
}
/**
* Execute the job.
*/
public function handle(): void
{
//Add Job UUID to the container
$this->container->jobuuid = $this->job->uuid();
JobLog::create([
'uuid' => $this->job->uuid(),
'jobname' => 'CancelInboundPlan',
'tablename' => 'inboundplans',
'entryid' => $this->container->databaseID
]);
$succ = app(Pipeline::class)
->send($this->container)
->through([
GetLabelDownloadURLPipeline::class,
])
->then(function(InboundShippingLabelContainer $container){
$updateDB = InboundPlan::where('inboundplanid',$container->inboundplanid)->where('account',$container->__get('account'))->update([
'labeldownloadurl' => $container->labeldownloadurl
]);
return $container;
});
}
/**
* Handle a job failure.
*/
public function failed(?Throwable $exception): void
{
if(boolval(env('APP_DEBUG'))){
DebugLog::create([
'function' => 'GetLabelsV0',
'object' => json_encode($this->container,JSON_PRETTY_PRINT),
'message' => $exception->getMessage()
]);
}
//SEND GET MESSAGE TO FAILURE WEBHOOK
}
}