Source for file Exception.php

Documentation is available at Exception.php

  1. <?php
  2. /** 
  3.  *  PHP Version 5
  4.  *
  5.  *  @category    Amazon
  6.  *  @package     Amazon_SimpleDB
  7.  *  @copyright   Copyright 2008 Amazon Technologies, Inc.
  8.  *  @link        http://aws.amazon.com
  9.  *  @license     http://aws.amazon.com/apache2.0  Apache License, Version 2.0
  10.  *  @version     2007-11-07
  11.  */
  12. /******************************************************************************* 
  13.  *    __  _    _  ___ 
  14.  *   (  )( \/\/ )/ __)
  15.  *   /__\ \    / \__ \
  16.  *  (_)(_) \/\/  (___/
  17.  * 
  18.  *  Amazon Simple DB PHP5 Library
  19.  *  Generated: Thu Aug 28 06:20:51 PDT 2008
  20.  * 
  21.  */
  22.  
  23.  
  24. /**
  25.  * Simple DB  Exception provides details of errors
  26.  * returned by Simple DB  service
  27.  *
  28.  */
  29. class Amazon_SimpleDB_Exception extends Exception
  30.  
  31. {
  32.     /** @var string */
  33.     private $_message null;
  34.     /** @var int */
  35.     private $_statusCode = -1;
  36.     /** @var string */
  37.     private $_errorCode null;
  38.     /** @var string */
  39.     private $_errorType null;
  40.     /** @var string */
  41.     private $_boxUsage null;
  42.     /** @var string */
  43.     private $_requestId null;
  44.     /** @var string */
  45.     private $_xml null;
  46.    
  47.  
  48.     /**
  49.      * Constructs Amazon_SimpleDB_Exception
  50.      * @param array $errorInfo details of exception.
  51.      *  Keys are:
  52.      *  <ul>
  53.      *  <li>Message - (string) text message for an exception</li>
  54.      *  <li>StatusCode - (int) HTTP status code at the time of exception</li>
  55.      *  <li>ErrorCode - (string) specific error code returned by the service</li>
  56.      *  <li>ErrorType - (string) Possible types:  Sender, Receiver or Unknown</li>
  57.      *  <li>BoxUsage - (string) Measure of machine utilization for this request.</li>
  58.      *  <li>RequestId - (string) request id returned by the service</li>
  59.      *  <li>XML - (string) compete xml response at the time of exception</li>
  60.      *  <li>Exception - (Exception) inner exception if any</li>
  61.      *  </ul>
  62.      *         
  63.      */
  64.     public function __construct(array $errorInfo array())
  65.     {
  66.         $this->_message $errorInfo["Message"];
  67.         parent::__construct($this->_message);
  68.         if (array_key_exists("Exception"$errorInfo)) {
  69.             $exception $errorInfo["Exception"];
  70.             if ($exception instanceof Amazon_SimpleDB_Exception{
  71.                 $this->_statusCode $exception->getStatusCode();
  72.                 $this->_errorCode $exception->getErrorCode();
  73.                 $this->_errorType $exception->getErrorType();
  74.                 $this->_boxUsage $exception->getBoxUsage();
  75.                 $this->_requestId $exception->getRequestId();
  76.                 $this->_xml$exception->getXML();
  77.             
  78.         else {
  79.             $this->_statusCode $errorInfo["StatusCode"];
  80.             $this->_errorCode $errorInfo["ErrorCode"];
  81.             $this->_errorType $errorInfo["ErrorType"];
  82.             $this->_boxUsage $errorInfo["BoxUsage"];
  83.             $this->_requestId $errorInfo["RequestId"];
  84.             $this->_xml$errorInfo["XML"];
  85.         }
  86.     }
  87.  
  88.     /**
  89.      * Gets error type returned by the service if available.
  90.      *
  91.      * @return string Error Code returned by the service
  92.      */
  93.     public function getErrorCode(){
  94.         return $this->_errorCode;
  95.     }
  96.    
  97.     /**
  98.      * Gets error type returned by the service.
  99.      *
  100.      * @return string Error Type returned by the service.
  101.      *  Possible types:  Sender, Receiver or Unknown
  102.      */
  103.     public function getErrorType(){
  104.         return $this->_errorType;
  105.     }
  106.     
  107.     /**
  108.      * Measure of machine utilization for this request.
  109.      *
  110.      * @return string Measure of machine utilization for this request.
  111.      */
  112.     public function getBoxUsage(){
  113.         return $this->_boxUsage;
  114.     }
  115.   
  116.     /**
  117.      * Gets error message
  118.      *
  119.      * @return string Error message
  120.      */
  121.     public function getErrorMessage({
  122.         return $this->_message;
  123.     }
  124.     
  125.     /**
  126.      * Gets status code returned by the service if available. If status
  127.      * code is set to -1, it means that status code was unavailable at the
  128.      * time exception was thrown
  129.      *
  130.      * @return int status code returned by the service
  131.      */
  132.     public function getStatusCode({
  133.         return $this->_statusCode;
  134.     }
  135.     
  136.     /**
  137.      * Gets XML returned by the service if available.
  138.      *
  139.      * @return string XML returned by the service
  140.      */
  141.     public function getXML({
  142.         return $this->_xml;
  143.     }
  144.     
  145.     /**
  146.      * Gets Request ID returned by the service if available.
  147.      *
  148.      * @return string Request ID returned by the service
  149.      */
  150.     public function getRequestId({
  151.         return $this->_requestId;
  152.     }
  153. }

Documentation generated on Thu, 28 Aug 2008 06:35:48 -0700 by phpDocumentor 1.4.2