laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.54k stars 11.02k forks source link

Queue:failing dose not return an exception nor job name in laravel5.7 #32607

Closed saeid78 closed 4 years ago

saeid78 commented 4 years ago

Hi, I have set up queue:failing in the boot method and was expecting to catch exception , but it only return connection Name! I have this : Queue::failing(function (JobFailed $event) { Log::error('JobFailed. ' . json_encode([ 'connectionName' => $event->connectionName, 'job' => $event->job, 'exception' => $event->exception ])); }); And this is my Command: command=php /var/www/html/artisan queue:work redis --sleep=3 --tries=3 --quiet Thanks!

taylorotwell commented 4 years ago

Sounds like a feature request, not a bug.

saeid78 commented 4 years ago

Thx @taylorotwell But I have followed https://laravel.com/docs/5.7/queues#failed-job-events Shouldn't I expect to get an Exception there? Do I need to bring this out somewhere else ? please advice.

mfn commented 4 years ago

The docs don't document everything, ::failed is the generalization.

There's another (in the docs undocumented) event ::exceptionOccurred which receives it:

        Queue::exceptionOccurred(function (JobExceptionOccurred $event) {
…

\Illuminate\Queue\Events\JobExceptionOccurred contains the job and the exception

saeid78 commented 4 years ago

Thx @mfn for the info!

boogiefromzk commented 2 years ago

@mfn Great feature, thank you!