40 lines
984 B
PHP
40 lines
984 B
PHP
<?php
|
|
|
|
namespace App\Job;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
/**
|
|
* Базовый класс для выполнения джобы
|
|
*/
|
|
class BaseJob implements ShouldQueue
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
/**
|
|
* Метод обработки ошибки при выполнении джобы
|
|
*
|
|
* @param \Throwable $th
|
|
* @return void
|
|
*/
|
|
public function failed(\Throwable $th): void
|
|
{
|
|
$context = [
|
|
//Скрипт откуда запустилась задача
|
|
'command' => static::class,
|
|
//Скрипт, в котором произошла ошибка
|
|
'file' => $th->getFile(),
|
|
'line' => $th->getLine(),
|
|
];
|
|
\Log::channel('job_err')->error($th->getMessage(), $context);
|
|
}
|
|
|
|
}
|
|
|