Expose parameter passed to exceptions

This commit is contained in:
Mathieu Pipet 2015-06-09 17:30:13 +02:00
parent c174b6fc65
commit c84ea1ea62
7 changed files with 22 additions and 0 deletions

View File

@ -32,6 +32,7 @@ class InvalidGrantException extends OAuthException
public function __construct($parameter)
{
$this->parameter = parameter;
parent::__construct(
sprintf(
'The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client. Check the "%s" parameter.',

View File

@ -32,6 +32,7 @@ class InvalidRequestException extends OAuthException
public function __construct($parameter, $redirectUri = null)
{
$this->parameter = parameter;
parent::__construct(
sprintf(
'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "%s" parameter.',

View File

@ -32,6 +32,7 @@ class InvalidScopeException extends OAuthException
public function __construct($parameter, $redirectUri = null)
{
$this->parameter = parameter;
parent::__construct(
sprintf(
'The requested scope is invalid, unknown, or malformed. Check the "%s" scope.',

View File

@ -36,6 +36,11 @@ class OAuthException extends \Exception
*/
public $errorType = '';
/**
* Parameter eventually passed to Exception
*/
public $parameter = '';
/**
* Throw a new exception
*
@ -72,6 +77,16 @@ class OAuthException extends \Exception
);
}
/**
* Return parameter if set
*
* @return string
*/
public function getParameter()
{
return $this->redirectUri;
}
/**
* Get all headers that have to be send with the error response
*

View File

@ -31,7 +31,9 @@ class ServerErrorException extends OAuthException
*/
public function __construct($parameter = null)
{
$this->parameter = parameter;
$parameter = is_null($parameter) ? 'The authorization server encountered an unexpected condition which prevented it from fulfilling the request.' : $parameter;
parent::__construct($parameter);
}
}

View File

@ -32,6 +32,7 @@ class UnsupportedGrantTypeException extends OAuthException
public function __construct($parameter)
{
$this->parameter = parameter;
parent::__construct(
sprintf(
'The authorization grant type "%s" is not supported by the authorization server.',

View File

@ -31,6 +31,7 @@ class UnsupportedResponseTypeException extends OAuthException
*/
public function __construct($parameter, $redirectUri = null)
{
$this->parameter = parameter;
parent::__construct('The authorization server does not support obtaining an access token using this method.');
$this->redirectUri = $redirectUri;
}