<?php declare(strict_types=1);

class QrbException extends ErrorException 
{
    private string $localizeKey;
    private ?string $additionalInformation = NULL;
    
    public function __construct(
        string $message,
        string $localizeKey,
        string $additionalInformation = NULL
        )
    {
        parent::__construct($message);
        $this->localizeKey = $localizeKey;
        $this->additionalInformation = $additionalInformation;
    }
    
    // Returns localize key
    public function getLocalizeKey() : string
    {
        return $this->localizeKey;
    }
    
    // Returns additional information if there is any, returns an empty string if there isn't.
    public function getAdditionalInformation() : string
    {
        return $this->additionalInformation ? $this->additionalInformation : "";
    }
    
    public function __toString() : string
    {
        $l = "Key: {$this->localizeKey}\n";
        $a = $this->additionalInformation ? "AdditionalInformation: {$this->additionalInformation}\n" : ""; 
        $p = parent::__toString();
        return $l . $a . $p;
    }
}

?>
