<?php

declare(strict_types=1);

namespace FecaMailshots\Domain;

final class AppError extends \RuntimeException
{
    private string $codeName;

    /** @var array<string, mixed> */
    private array $context;

    /** @param array<string, mixed> $context */
    public function __construct(string $codeName, string $message, array $context = [], int $code = 0, ?\Throwable $previous = null)
    {
        parent::__construct($message, $code, $previous);
        $this->codeName = $codeName;
        $this->context = $context;
    }

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

    /** @return array<string, mixed> */
    public function context(): array
    {
        return $this->context;
    }
}
