HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/xedaptot/ai.naniguide.com/app/Jobs/Concerns/LogsJobFailure.php
<?php

namespace App\Jobs\Concerns;

use Illuminate\Support\Facades\Log;
use Throwable;

/**
 * Shared failed() callback for SendMessage and SendSingleMessage. Both jobs
 * emit the same structured [JOB_FAILED] log line — ops scrapes this format,
 * keep stable.
 *
 * The two jobs intentionally do not share an inheritance hierarchy (their
 * constructor signatures are different); this trait is the minimal bit they
 * actually share.
 */
trait LogsJobFailure
{
    public function failed(Throwable $exception): void
    {
        Log::error('[JOB_FAILED] '.static::class, [
            'exception' => $exception->getMessage(),
            'file' => $exception->getFile(),
            'line' => $exception->getLine(),
            'campaign_uid' => $this->campaign->uid ?? null,
            'subscriber_email' => $this->subscriber->email ?? null,
        ]);
    }
}