TimeoutExceededException.php
TLDR
The TimeoutExceededException.php
file contains the TimeoutExceededException
class, which extends the MaxAttemptsExceededException
class. It provides a static method forJob
that creates a new instance of the exception for a specific job.
Classes
TimeoutExceededException
The TimeoutExceededException
class extends the MaxAttemptsExceededException
class and represents an exception that is thrown when a job execution exceeds its timeout. It provides a static method forJob
that creates a new instance of the exception for a specific job.
The class has the following method:
-
forJob($job)
- This method creates a new instance of theTimeoutExceededException
for a given job. It resolves the name of the job and sets it as part of the exception message. It also sets the job instance to the exception instance. The method returns the created exception instance.
<?php
namespace Illuminate\Queue;
class TimeoutExceededException extends MaxAttemptsExceededException
{
/**
* Create a new instance for the job.
*
* @param \Illuminate\Contracts\Queue\Job $job
* @return static
*/
public static function forJob($job)
{
return tap(new static($job->resolveName().' has timed out.'), function ($e) use ($job) {
$e->job = $job;
});
}
}