-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
There is currently not a way to nicely handle all exceptions in closures:
$schedule->run(fn => throw new Exception())
The closure will be serialized and run in a seperate process, so on_error or set_exception_handler won't work. Even setting an exception handler in the closure itself won't work, as the exception is actually caught higher up in the console command, meaning the exception_handler won't be called.
Instead, to handle these exceptions, all closures currently can be wrapped in a try-catch:
$schedule->run(
static function () {
try {
throw new Exception();
catch (Throwable $e) {
// log error to somewhere
}
}
)
This is the way we are currently handling these, but it would be nice to be able to serialize an exceptionHandler together with the closure. Would you be open to something like that?
Metadata
Metadata
Assignees
Labels
No labels