<?php

namespace AuthStack\OAuth2\Exception;

use Throwable;

class OAuth2Exception extends \Exception
{
    const E_INVALID_REQUEST = 'invalid_request';
    const E_UNAUTHORIZED_CLIENT = 'unauthorized_client';
    const E_INVALID_CLIENT = 'invalid_client';
    const E_ACCESS_DENIED  = 'access_denied';
    const E_UNSUPPORTED_RESP_TYPE = 'unsupported_response_type';
    const E_INVALID_SCOPE = 'invalid_scope';
    const E_SERVER_ERROR = 'server_error';
    const E_TEMPORARILY_UNAVAILABLE = 'temporarily_unavailable';

    protected $error_code;
    protected $error_description;
    protected $error_uri;

    public function __construct(string $error_code, string $error_description = '', string $error_uri = '',  string $message = "", int $code = 0, Throwable $previous = null)
    {
        parent::__construct($message, $code, $previous);

        $this->error_code = $error_code;
        $this->error_description = $error_description;
        $this->error_uri = $error_uri;
    }

    /**
     * @return string
     */
    public function getOAuthErrorCode(): string
    {
        return $this->error_code;
    }

    /**
     * @return string
     */
    public function getErrorDescription(): string
    {
        return $this->error_description;
    }

    /**
     * @return string
     */
    public function getErrorUri(): string
    {
        return $this->error_uri;
    }
}