CRM-15603 - Standardize format of 'Non-deductible Amount'
[civicrm-core.git] / api / Exception.php
index ea4705820e010eeb8997a1ef0eb8cd6996d4dfdb..953fafdbe99e97481b0ca72d98914c9ddcb276a6 100644 (file)
@@ -5,7 +5,7 @@
  * @package CiviCRM_APIv3
  * @subpackage API
  *
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  */
 
 /**
  */
 class API_Exception extends Exception
 {
+  const UNAUTHORIZED = 'unauthorized';
+  const NOT_IMPLEMENTED = 'not-found';
+
   private $extraParams = array();
+
+  /**
+   * @param string $message
+   * @param int $error_code
+   * @param array $extraParams
+   * @param Exception $previous
+   */
   public function __construct($message, $error_code = 0, $extraParams = array(),Exception $previous = null) {
     if (is_numeric ($error_code)) // using int for error code "old way")
       $code = $error_code;
@@ -32,19 +42,30 @@ class API_Exception extends Exception
   }
 
   // custom string representation of object
+  /**
+   * @return string
+   */
   public function __toString() {
     return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
   }
 
+  /**
+   * @return array
+   */
   public function getExtraParams() {
     return $this->extraParams;
   }
 
+  /**
+   * @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'
+        2100 => 'String value is longer than permitted length',
+        self::UNAUTHORIZED => 'Unauthorized',
+        self::NOT_IMPLEMENTED => 'Entity or method is not implemented',
         );
   }
 }
@@ -59,12 +80,22 @@ class API_Exception extends Exception
 class CiviCRM_API3_Exception extends Exception
 {
   private $extraParams = array();
+
+  /**
+   * @param string $message
+   * @param int $error_code
+   * @param array $extraParams
+   * @param Exception $previous
+   */
   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";
   }
@@ -72,6 +103,10 @@ class CiviCRM_API3_Exception extends Exception
   public function getErrorCode() {
     return $this->extraParams['error_code'];
   }
+
+  /**
+   * @return array
+   */
   public function getExtraParams() {
     return $this->extraParams;
   }