Skip to content

Commit

Permalink
Fix for class extends from (missing start slash). Added Exception cod…
Browse files Browse the repository at this point in the history
…e name.
  • Loading branch information
drsdre committed Jan 6, 2017
1 parent 96e49c1 commit 2097479
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

nbproject
vendor
composer.phar
composer.lock
.idea

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk
4 changes: 1 addition & 3 deletions Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
* @see http://v2.wp-api.org/
*
* @author Andre Schuurman <[email protected]>
* @since 2.0
*
*/
class Client extends yii\base\Object {
class Client extends \yii\base\Object {

/**
* @var string API endpoint (default production)
Expand Down
19 changes: 16 additions & 3 deletions Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,33 @@
* Error codes handling retry and other specific conditions
*
* @author Andre Schuurman <[email protected]>
* @since 2.0
*/
class Exception extends yii\base\Exception {
class Exception extends \yii\base\Exception {

const FAIL = 0;
const RETRY = 1;
const WAIT_RETRY = 2;
const ITEM_EXISTS = 3;

static $code_names = [
self::FAIL => ' unrecoverable',
self::RETRY => ' and can be retried',
self::WAIT_RETRY => ' and can be retried after wait time',
self::ITEM_EXISTS => ' because item already exists',
];

/**
* @return string the user-friendly name of this exception
*/
public function getName()
{
return 'API response failed, retry';
return 'API request failed'.$this->getCodeName();
}

/**
* @return mixed|string
*/
public function getCodeName() {
return isset(self::$code_names[$this->getCode()])?self::$code_names[$this->getCode()]:'';
}
}
3 changes: 1 addition & 2 deletions OAuth1.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
* @see https://wordpress.org/plugins/rest-api-oauth1/
*
* @author Andre Schuurman <[email protected]>
* @since 2.0
*/
class OAuth1 extends yii\authclient\OAuth1
class OAuth1 extends \yii\authclient\OAuth1
{
/**
* @inheritdoc
Expand Down

0 comments on commit 2097479

Please sign in to comment.