I am trying to catch an exception inside a job but it seems the try/catch bock has no effect.
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$progress=0;
$step=100/count($this->itemsId);
event(new JobProgressUpdate($progress, '', true, $this->broadcastChannel));
foreach ($this->itemsId as $itemId) {
$message='ITEM '.$itemId.': ';
$success=true;
try{
$this->meliCredential->setItemStatus($itemId,$this->status);
}catch(\Exception $e){
$message+=$e->getMessage();
$success=false;
}
$progress+=$step;
event(new JobProgressUpdate($progress, $message, $success, $this->broadcastChannel));
}
}
The idea is to avoid the job to be marked as failed and just send a message of the exception to the client.
so the question is, How to catch exceptions inside a job handler???
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire