<?php

namespace App\Classes\Exceptions;

use App\Classes\ValueObjects\Constants\HttpStatus;
use Illuminate\Support\Facades\Log;

final class ConnectionErrorException extends ServiceApiException {
    public function __construct(?string $message = null, ?string $exceptionMessage = null, ?string $payload = null, ?string $exceptionTrace = null) {
        Log::error($message. ": ". $exceptionMessage);
        if($payload){
            Log::error('Payload: '.$payload);
        }
        if($exceptionTrace){
            Log::error($exceptionTrace);
        }
        parent::__construct($message ?? 'A connection error has occurred. Please check application logs for more information.',
            HttpStatus::SERVER_ERROR);
    }
}
