Reputation: 6645
When using queueable notifications:
class MyNotification extends Notification implements ShouldQueue
{
use Queueable;
}
How do I handle failed jobs? If I'd have dispatched the email/notification via a job class I could use the failed method:
public function failed(Exception $exception) {
Log::debug('MyNotification failed');
}
However the failed method in a notification doesn't work
Upvotes: 0
Views: 1498
Reputation: 6645
Caddy DZ is correct there is a handle() method for notifications: https://github.com/illuminate/notifications/blob/master/SendQueuedNotifications.php#L92
My issue was not importing the Exception class, code should be:
public function failed(\Exception $exception) {
Log::debug('MyNotification failed');
}
Upvotes: 1
Reputation: 385
You should check Laravel documentation here.
For example, in your AppServiceProvider you can add:
public function boot()
{
Queue::failing(function (JobFailed $event) {
// $event->connectionName
// $event->job
// $event->exception
});
}
Handling of the failed job is not responsibility of the notifications but of the queues.
Upvotes: 1