This file is indexed.

/usr/share/civicrm/api/Exception.php is in civicrm-common 4.7.30+dfsg-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
 * @file
 * File for the CiviCRM APIv3 API wrapper
 *
 * @package CiviCRM_APIv3
 *
 * @copyright CiviCRM LLC (c) 2004-2017
 */

/**
 * This api exception returns more information than the default one. The aim
 * it let the api consumer know better what is exactly the error without
 * having to parse the error message.
 *
 * If you consume an api that doesn't return an error_code or the extra data
 * you need, consider improving the api and contribute.
 */
class API_Exception extends Exception {
  const UNAUTHORIZED = 'unauthorized';
  const NOT_IMPLEMENTED = 'not-found';

  private $extraParams = array();

  /**
   * Class constructor.
   *
   * @param string $message
   *   The human friendly error message.
   * @param mixed $error_code
   *   A computer friendly error code. By convention, no space (but underscore
   *   allowed) (ex: mandatory_missing, duplicate, invalid_format).
   * @param array $extraParams
   *   Extra params to return. eg an extra array of ids. It is not mandatory,
   *   but can help the computer using the api. Keep in mind the api consumer
   *   isn't to be trusted. eg. the database password is NOT a good extra data.
   * @param Exception|NULL $previous
   *   A previous exception which caused this new exception.
   */
  public function __construct($message, $error_code = 0, $extraParams = array(), Exception $previous = NULL) {
    // Using int for error code "old way") ?
    if (is_numeric($error_code)) {
      $code = $error_code;
    }
    else {
      $code = 0;
    }
    parent::__construct(ts($message), $code, $previous);
    $this->extraParams = $extraParams + array('error_code' => $error_code);
  }

  /**
   * Custom string representation of object.
   *
   * @return string
   */
  public function __toString() {
    return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
  }

  /**
   * Get extra parameters.
   *
   * @return array
   */
  public function getExtraParams() {
    return $this->extraParams;
  }

  /**
   * Get error codes.
   *
   * @return array
   */
  public function getErrorCodes() {
    return array(
      2000 => '$params was not an array',
      2001 => 'Invalid Value for Date field',
      2100 => 'String value is longer than permitted length',
      self::UNAUTHORIZED => 'Unauthorized',
      self::NOT_IMPLEMENTED => 'Entity or method is not implemented',
    );
  }

}

/**
 * This api exception returns more information than the default one. We are using it rather than
 * API_Exception from the api wrapper as the namespace is more generic
 */
class CiviCRM_API3_Exception extends Exception {
  private $extraParams = array();

  /**
   * Class constructor.
   *
   * @param string $message
   *   The human friendly error message.
   * @param mixed $error_code
   *   A computer friendly error code. By convention, no space (but underscore
   *   allowed) (ex: mandatory_missing, duplicate, invalid_format).
   * @param array $extraParams
   *   Extra params to return. eg an extra array of ids. It is not mandatory,
   *   but can help the computer using the api. Keep in mind the api consumer
   *   isn't to be trusted. eg. the database password is NOT a good extra data.
   * @param Exception|NULL $previous
   *   A previous exception which caused this new exception.
   */
  public function __construct($message, $error_code, $extraParams = array(), Exception $previous = NULL) {
    parent::__construct(ts($message));
    $this->extraParams = $extraParams + array('error_code' => $error_code);
  }

  /**
   * Custom string representation of object.
   *
   * @return string
   */
  public function __toString() {
    return __CLASS__ . ": [{$this->extraParams['error_code']}: {$this->message}\n";
  }

  /**
   * Get error code.
   *
   * @return mixed
   */
  public function getErrorCode() {
    return $this->extraParams['error_code'];
  }

  /**
   * Get extra parameters.
   *
   * @return array
   */
  public function getExtraParams() {
    return $this->extraParams;
  }

}