= 0) { parent::__construct($message, $code, $previous); } else { parent::__construct($message, $code); } $this->errors = $errors; if (is_array($retryMap)) { $this->retryMap = $retryMap; } } /** * An example of the possible errors returned. * * { * "domain": "global", * "reason": "authError", * "message": "Invalid Credentials", * "locationType": "header", * "location": "Authorization", * } * * @return [{string, string}] List of errors return in an HTTP response or []. */ public function getErrors() { return $this->errors; } /** * Gets the number of times the associated task can be retried. * * NOTE: -1 is returned if the task can be retried indefinitely * * @return integer */ public function allowedRetries() { if (isset($this->retryMap[$this->code])) { return $this->retryMap[$this->code]; } $errors = $this->getErrors(); if (!empty($errors) && isset($errors[0]['reason']) && isset($this->retryMap[$errors[0]['reason']])) { return $this->retryMap[$errors[0]['reason']]; } return 0; } }