Skip to content

Commit 0174b7d

Browse files
committed
add the exception to JobReleasedAfterException
1 parent 24a4568 commit 0174b7d

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/Illuminate/Queue/Events/JobReleasedAfterException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ class JobReleasedAfterException
1010
* @param string $connectionName The connection name.
1111
* @param \Illuminate\Contracts\Queue\Job $job The job instance.
1212
* @param int|null $backoff The backoff delay.
13+
* @param \Throwable|null $exception The exception that caused the job to be released.
1314
*/
1415
public function __construct(
1516
public $connectionName,
1617
public $job,
17-
public $backoff = null
18+
public $backoff = null,
19+
public $exception = null,
1820
) {
1921
}
2022
}

src/Illuminate/Queue/Worker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ protected function handleJobException($connectionName, $job, WorkerOptions $opti
614614
$job->release($backoff);
615615

616616
$this->events->dispatch(new JobReleasedAfterException(
617-
$connectionName, $job, $backoff
617+
$connectionName, $job, $backoff, $e
618618
));
619619
}
620620
}

tests/Queue/QueueWorkerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,12 @@ public function testJobReleasedEvent()
624624
$worker = $this->getWorker('default', ['queue' => [$job]]);
625625
$worker->runNextJob('default', 'queue', $this->workerOptions(['backoff' => 10]));
626626

627-
$this->events->shouldHaveReceived('dispatch')->with(m::on(function ($event) use ($job) {
627+
$this->events->shouldHaveReceived('dispatch')->with(m::on(function ($event) use ($job, $e) {
628628
return $event instanceof JobReleasedAfterException
629629
&& $event->connectionName === 'default'
630630
&& $event->job === $job
631-
&& $event->backoff === 10;
631+
&& $event->backoff === 10
632+
&& $event->exception === $e;
632633
}))->once();
633634
}
634635

0 commit comments

Comments
 (0)