Skip to content

Conversation

timacdonald
Copy link
Member

@timacdonald timacdonald commented Mar 3, 2024

The exception may be null if you call the fail method without passing a string or exception, as documented.

Screen Shot 2024-03-04 at 9 02 43 am

So having this nullable in the docs seems more sensible, as the two documented version do not currently work together. If this were typed with Throwable an exception would be thrown when the queue worker attempts to call the job's failed method.

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class TestJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function handle(): void
    {
        $this->fail();
    }

    public function failed($e)
    {
        dd($e); // null
    }
}

@taylorotwell taylorotwell merged commit 215d89e into laravel:10.x Mar 4, 2024
@timacdonald timacdonald deleted the failed branch March 4, 2024 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants