Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
103 - 1
<?php
2
/*
3
 * Copyright 2014 Google Inc.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
 
18
class Google_Service_Exception extends Google_Exception
19
{
20
  /**
21
   * Optional list of errors returned in a JSON body of an HTTP error response.
22
   */
23
  protected $errors = array();
24
 
25
  /**
26
   * Override default constructor to add the ability to set $errors and a retry
27
   * map.
28
   *
29
   * @param string $message
30
   * @param int $code
31
   * @param Exception|null $previous
32
   * @param [{string, string}] errors List of errors returned in an HTTP
33
   * response.  Defaults to [].
34
   * @param array|null $retryMap Map of errors with retry counts.
35
   */
36
  public function __construct(
37
      $message,
38
      $code = 0,
39
      Exception $previous = null,
40
      $errors = array()
41
  ) {
42
    if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
43
      parent::__construct($message, $code, $previous);
44
    } else {
45
      parent::__construct($message, $code);
46
    }
47
 
48
    $this->errors = $errors;
49
  }
50
 
51
  /**
52
   * An example of the possible errors returned.
53
   *
54
   * {
55
   *   "domain": "global",
56
   *   "reason": "authError",
57
   *   "message": "Invalid Credentials",
58
   *   "locationType": "header",
59
   *   "location": "Authorization",
60
   * }
61
   *
62
   * @return [{string, string}] List of errors return in an HTTP response or [].
63
   */
64
  public function getErrors()
65
  {
66
    return $this->errors;
67
  }
68
}