-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exception.php
54 lines (45 loc) · 1.48 KB
/
Exception.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @link https://github.com/borodulin/yii2-oauth2-server
* @copyright Copyright (c) 2015 Andrey Borodulin
* @license https://github.com/borodulin/yii2-oauth2-server/blob/master/LICENSE
*/
namespace yuncms\oauth2;
use yii\base\UserException;
/**
* Class Exception
* @package yuncms\oauth2
*/
class Exception extends UserException
{
const ACCESS_DENIED = 'access_denied';
const INVALID_CLIENT = 'invalid_client';
const INVALID_GRANT = 'invalid_grant';
const INVALID_REQUEST = 'invalid_request';
const INVALID_SCOPE = 'invalid_scope';
const REDIRECT_URI_MISMATCH = 'redirect_uri_mismatch';
const SERVER_ERROR = 'server_error';
const TEMPORARILY_UNAVAILABLE = 'temporarily_unavailable';
const UNAUTHORIZED_CLIENT = 'unauthorized_client';
const UNSUPPORTED_GRANT_TYPE = 'unsupported_grant_type';
const UNSUPPORTED_RESPONSE_TYPE = 'unsupported_response_type';
const NOT_IMPLEMENTED = 'not_implemented';
protected $error;
/**
* Constructor.
* @param string $errorDescription (optional)
* @param string $error A single error code
*/
public function __construct($errorDescription = null, $error = self::INVALID_REQUEST)
{
$this->error = $error;
parent::__construct($errorDescription, 0, null);
}
/**
* @return string the user-friendly name of this exception
*/
public function getName()
{
return isset($this->error) ? $this->error : self::SERVER_ERROR;
}
}