<?php

namespace QUI\MasterLogin;

use QUI;

/**
 * Class PermissionDeniedException
 *
 * Thrown if an unpermitted action is executed
 */
class PermissionDeniedException extends Exception
{
    /**
     * @var int
     */
    protected $code = 401;

    /**
     * Constructor
     *
     * @param string|array<int|string, mixed>|null $message - Text der Exception
     * @param integer $code - Error code der Exception
     * @param array<string, mixed> $context - [optional] Context data, which data
     */
    public function __construct($message = null, int $code = 0, array $context = [])
    {
        if (empty($message)) {
            $message = QUI::getLocale()->get(
                'quiqqer/masterlogin',
                'exception.permission_denied'
            );
        }

        parent::__construct($message, $code, $context);
    }
}
