1
0
Fork 0
mirror of https://github.com/archtechx/jobpipeline.git synced 2025-12-12 19:04:03 +00:00

adds error catching to handle method

This commit is contained in:
hackerESQ 2022-03-17 19:10:30 -05:00 committed by GitHub
parent 15b38fbcdb
commit 80947a4889
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Stancl\JobPipeline;
use Closure;
use Throwable;
use Illuminate\Contracts\Queue\ShouldQueue;
class JobPipeline implements ShouldQueue
@ -63,7 +64,18 @@ class JobPipeline implements ShouldQueue
$job = [new $job(...$this->passable), 'handle'];
}
$result = app()->call($job);
try {
$result = app()->call($job);
} catch(Throwable $exception) {
if ( method_exists(get_class($job[0]), 'failed') ) {
call_user_func_array([$job[0], 'failed'], [$exception]);
} else {
Log::error($exception);
}
break;
}
if ($result === false) {
break;