<?php

namespace Sibs\Stargate\Exceptions;

use Sibs\Stargate\Loggers\SibsLogger;

defined('ABSPATH') || exit;

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

    /**
     * Constructor.
     */
    public function __construct(string $details = '', array $context = [])
    {
        parent::__construct($details);

        $this->details = $details;

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

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

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