Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp.../includes/Google/Service
File: Exception.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* Copyright 2014 Google Inc.
[2] Fix | Delete
*
[3] Fix | Delete
* Licensed under the Apache License, Version 2.0 (the "License");
[4] Fix | Delete
* you may not use this file except in compliance with the License.
[5] Fix | Delete
* You may obtain a copy of the License at
[6] Fix | Delete
*
[7] Fix | Delete
* http://www.apache.org/licenses/LICENSE-2.0
[8] Fix | Delete
*
[9] Fix | Delete
* Unless required by applicable law or agreed to in writing, software
[10] Fix | Delete
* distributed under the License is distributed on an "AS IS" BASIS,
[11] Fix | Delete
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
[12] Fix | Delete
* See the License for the specific language governing permissions and
[13] Fix | Delete
* limitations under the License.
[14] Fix | Delete
*/
[15] Fix | Delete
[16] Fix | Delete
if (!class_exists('UDP_Google_Client')) {
[17] Fix | Delete
require_once dirname(__FILE__) . '/../autoload.php';
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
class UDP_Google_Service_Exception extends Google_Exception implements Google_Task_Retryable
[21] Fix | Delete
{
[22] Fix | Delete
/**
[23] Fix | Delete
* Optional list of errors returned in a JSON body of an HTTP error response.
[24] Fix | Delete
*/
[25] Fix | Delete
protected $errors = array();
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* @var array $retryMap Map of errors with retry counts.
[29] Fix | Delete
*/
[30] Fix | Delete
private $retryMap = array();
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Override default constructor to add the ability to set $errors and a retry
[34] Fix | Delete
* map.
[35] Fix | Delete
*
[36] Fix | Delete
* @param string $message
[37] Fix | Delete
* @param int $code
[38] Fix | Delete
* @param Exception|null $previous
[39] Fix | Delete
* @param [{string, string}] errors List of errors returned in an HTTP
[40] Fix | Delete
* response. Defaults to [].
[41] Fix | Delete
* @param array|null $retryMap Map of errors with retry counts.
[42] Fix | Delete
*/
[43] Fix | Delete
public function __construct(
[44] Fix | Delete
$message,
[45] Fix | Delete
$code = 0,
[46] Fix | Delete
Exception $previous = null,
[47] Fix | Delete
$errors = array(),
[48] Fix | Delete
array $retryMap = null
[49] Fix | Delete
) {
[50] Fix | Delete
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
[51] Fix | Delete
parent::__construct($message, $code, $previous);
[52] Fix | Delete
} else {
[53] Fix | Delete
parent::__construct($message, $code);
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
$this->errors = $errors;
[57] Fix | Delete
[58] Fix | Delete
if (is_array($retryMap)) {
[59] Fix | Delete
$this->retryMap = $retryMap;
[60] Fix | Delete
}
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* An example of the possible errors returned.
[65] Fix | Delete
*
[66] Fix | Delete
* {
[67] Fix | Delete
* "domain": "global",
[68] Fix | Delete
* "reason": "authError",
[69] Fix | Delete
* "message": "Invalid Credentials",
[70] Fix | Delete
* "locationType": "header",
[71] Fix | Delete
* "location": "Authorization",
[72] Fix | Delete
* }
[73] Fix | Delete
*
[74] Fix | Delete
* @return [{string, string}] List of errors return in an HTTP response or [].
[75] Fix | Delete
*/
[76] Fix | Delete
public function getErrors()
[77] Fix | Delete
{
[78] Fix | Delete
return $this->errors;
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Gets the number of times the associated task can be retried.
[83] Fix | Delete
*
[84] Fix | Delete
* NOTE: -1 is returned if the task can be retried indefinitely
[85] Fix | Delete
*
[86] Fix | Delete
* @return integer
[87] Fix | Delete
*/
[88] Fix | Delete
public function allowedRetries()
[89] Fix | Delete
{
[90] Fix | Delete
if (isset($this->retryMap[$this->code])) {
[91] Fix | Delete
return $this->retryMap[$this->code];
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
$errors = $this->getErrors();
[95] Fix | Delete
[96] Fix | Delete
if (!empty($errors) && isset($errors[0]['reason']) &&
[97] Fix | Delete
isset($this->retryMap[$errors[0]['reason']])) {
[98] Fix | Delete
return $this->retryMap[$errors[0]['reason']];
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
return 0;
[102] Fix | Delete
}
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function