Skip to content

Commit 2f44389

Browse files
authored
handle exceptions in batch callbacks (#38327)
1 parent 7b88554 commit 2f44389

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Illuminate/Bus/Batch.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,15 @@ public function delete()
427427
*/
428428
protected function invokeHandlerCallback($handler, Batch $batch, Throwable $e = null)
429429
{
430-
return $handler instanceof SerializableClosure
431-
? $handler->__invoke($batch, $e)
432-
: call_user_func($handler, $batch, $e);
430+
try {
431+
return $handler instanceof SerializableClosure
432+
? $handler->__invoke($batch, $e)
433+
: call_user_func($handler, $batch, $e);
434+
} catch (Throwable $e) {
435+
if (function_exists('report')) {
436+
report($e);
437+
}
438+
}
433439
}
434440

435441
/**

0 commit comments

Comments
 (0)