<?php

namespace Sibs\Stargate\Exceptions;

use Exception;
use Sibs\Stargate\Constants\Logs;
use Sibs\Stargate\Loggers\SibsLogger;

defined('ABSPATH') || exit;

class SibsException extends \Exception
{
    /**
     * @var string
     */
    protected $details;

    /**
     * Constructor.
     */
    public function __construct(string $details = '', string $log_source = Logs::DEFAULT)
    {
        $this->details = $details;
        parent::__construct();

        if (function_exists('wc_get_logger')) {
            SibsLogger::error($this->getErrorMessage(), $log_source);
        }
    }

    /**
     * get Exception Message.
     *
     * @return string
     */
    public function getExceptionMessage()
    {
        return "{$this->details}";
    }

    /**
     * Get Error Message.
     *
     * @return string
     */
    public function getErrorMessage()
    {
        return "SIBS Error: {$this->details}";
    }
}
