<?php

namespace engine\http\errors;

use engine\http\HTTPCode;
use Throwable;

abstract class HTTPError
    extends \Exception
{
    protected HTTPCode $http_code;
    protected string $description;

    public function __construct(HTTPCode $code,
                                string $message,
                                ?Throwable $previous = null) {
        $this->http_code = $code;
        $this->description = $message;
        parent::__construct($message, $code->value, $previous);
    }

    public function getHTTPCode(): HTTPCode {
        return $this->http_code;
    }

    public function getDescription(): string {
        return $this->description;
    }
}