mirror of
https://github.com/archtechx/jobpipeline.git
synced 2025-12-12 13:54:03 +00:00
adds error catching to handle method
This commit is contained in:
parent
15b38fbcdb
commit
80947a4889
1 changed files with 13 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||||
namespace Stancl\JobPipeline;
|
namespace Stancl\JobPipeline;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Throwable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
class JobPipeline implements ShouldQueue
|
class JobPipeline implements ShouldQueue
|
||||||
|
|
@ -63,7 +64,18 @@ class JobPipeline implements ShouldQueue
|
||||||
$job = [new $job(...$this->passable), 'handle'];
|
$job = [new $job(...$this->passable), 'handle'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$result = app()->call($job);
|
$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) {
|
if ($result === false) {
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue