<?php

namespace App\Shared\Exception;

use App\Shared\Constant\ErrorCodes;

class AppException extends \RuntimeException
{
    public function __construct(
        private readonly string $errorCode,
        ?string $message = null,
        private readonly int $httpStatus = 400,
        private readonly ?string $field = null,
    ) {
        parent::__construct($message ?? ErrorCodes::message($errorCode));
    }

    public function getErrorCode(): string  { return $this->errorCode; }
    public function getHttpStatus(): int    { return $this->httpStatus; }
    public function getField(): ?string     { return $this->field; }
}
