| 1 |
<?php |
| 2 |
|
| 3 |
require_once ANALYTIFY_LIB_PATH . 'Google/Exception.php'; |
| 4 |
|
| 5 |
class Analytify_Google_Service_Exception extends Analytify_Google_Exception |
| 6 |
{ |
| 7 |
/** |
| 8 |
* Optional list of errors returned in a JSON body of an HTTP error response. |
| 9 |
*/ |
| 10 |
protected $errors = array(); |
| 11 |
|
| 12 |
/** |
| 13 |
* Override default constructor to add ability to set $errors. |
| 14 |
* |
| 15 |
* @param string $message |
| 16 |
* @param int $code |
| 17 |
* @param Exception|null $previous |
| 18 |
* @param [{string, string}] errors List of errors returned in an HTTP |
| 19 |
* response. Defaults to []. |
| 20 |
*/ |
| 21 |
public function __construct( |
| 22 |
$message, |
| 23 |
$code = 0, |
| 24 |
Exception $previous = null, |
| 25 |
$errors = array() |
| 26 |
) { |
| 27 |
if (version_compare(PHP_VERSION, '5.3.0') >= 0) { |
| 28 |
parent::__construct($message, $code, $previous); |
| 29 |
} else { |
| 30 |
parent::__construct($message, $code); |
| 31 |
} |
| 32 |
|
| 33 |
$this->errors = $errors; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* An example of the possible errors returned. |
| 38 |
* |
| 39 |
* { |
| 40 |
* "domain": "global", |
| 41 |
* "reason": "authError", |
| 42 |
* "message": "Invalid Credentials", |
| 43 |
* "locationType": "header", |
| 44 |
* "location": "Authorization", |
| 45 |
* } |
| 46 |
* |
| 47 |
* @return [{string, string}] List of errors return in an HTTP response or []. |
| 48 |
*/ |
| 49 |
public function getErrors() |
| 50 |
{ |
| 51 |
return $this->errors; |
| 52 |
} |
| 53 |
} |
| 54 |
|