Merged in feature/from-pantheon (pull request #16)
code from pantheon * code from pantheon
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Yoast\WP\SEO\Exceptions\OAuth;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class Authentication_Failed_Exception
|
||||
*/
|
||||
class Authentication_Failed_Exception extends Exception {
|
||||
|
||||
/**
|
||||
* Authentication_Failed_Exception constructor.
|
||||
*
|
||||
* @param Exception $original_exception The original exception.
|
||||
*/
|
||||
public function __construct( Exception $original_exception ) {
|
||||
parent::__construct( 'Authentication failed', 401, $original_exception );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted response object.
|
||||
*
|
||||
* @return object The response object.
|
||||
*/
|
||||
public function get_response() {
|
||||
return (object) [
|
||||
'tokens' => [],
|
||||
'error' => $this->getMessage() . ': ' . $this->getPrevious()->getMessage(),
|
||||
'status' => $this->getCode(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Yoast\WP\SEO\Exceptions\OAuth\Tokens;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class Empty_Property_Exception
|
||||
*/
|
||||
class Empty_Property_Exception extends Exception {
|
||||
|
||||
/**
|
||||
* Empty_Property_Exception constructor.
|
||||
*
|
||||
* @param string $property The property that is empty.
|
||||
*/
|
||||
public function __construct( $property ) {
|
||||
parent::__construct( \sprintf( 'Token creation failed. Property `%s` cannot be empty.', $property ), 400 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Yoast\WP\SEO\Exceptions\OAuth\Tokens;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class Empty_Token_Exception
|
||||
*/
|
||||
class Empty_Token_Exception extends Exception {
|
||||
|
||||
/**
|
||||
* Empty_Token_Exception constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct( 'Token usage failed. Token is empty.', 400 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Yoast\WP\SEO\Exceptions\OAuth\Tokens;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class Failed_Storage_Exception
|
||||
*/
|
||||
class Failed_Storage_Exception extends Exception {
|
||||
|
||||
const DEFAULT_MESSAGE = 'Token storing failed. Please try again.';
|
||||
|
||||
/**
|
||||
* Failed_Storage_Exception constructor.
|
||||
*
|
||||
* @param string $reason The reason why token storage failed. Optional.
|
||||
*/
|
||||
public function __construct( $reason = '' ) {
|
||||
$message = ( $reason ) ? \sprintf( 'Token storing failed. Reason: %s. Please try again', $reason ) : self::DEFAULT_MESSAGE;
|
||||
|
||||
parent::__construct( $message, 500 );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user