Services_Twitter
[ class tree: Services_Twitter ] [ index: Services_Twitter ] [ all elements ]

Source for file Exception.php

Documentation is available at Exception.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * An interface for Twitter's HTTP API
  7.  *
  8.  * PHP version 5.1.0+
  9.  *
  10.  * @category  Services
  11.  * @package   Services_Twitter
  12.  * @author    Joe Stump <joe@joestump.net>
  13.  * @author    David Jean Louis <izimobil@gmail.com>
  14.  * @copyright 1997-2008 Joe Stump <joe@joestump.net>
  15.  * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
  16.  * @version   SVN: $Id: Exception.php 39 2009-01-06 12:15:17Z izimobil $
  17.  * @link      http://twitter.com
  18.  * @link      http://apiwiki.twitter.com
  19.  * @filesource
  20.  */
  21.  
  22. require_once 'PEAR/Exception.php';
  23.  
  24. /**
  25.  * Exception raised by this package.
  26.  *
  27.  * @category Services
  28.  * @package  Services_Twitter
  29.  * @author   Joe Stump <joe@joestump.net>
  30.  * @author   David Jean Louis <izimobil@gmail.com>
  31.  * @license  http://www.opensource.org/licenses/bsd-license.php New BSD License
  32.  * @link     http://twitter.com
  33.  * @link     http://apiwiki.twitter.com
  34.  */
  35. class Services_Twitter_Exception extends PEAR_Exception
  36. {
  37.     // properties {{{
  38.  
  39.     /**
  40.      * Call to the API that created the error
  41.      *
  42.      * @var string $call 
  43.      */
  44.     protected $call = '';
  45.  
  46.     /**
  47.      * The HTTP response returned by the API
  48.      *
  49.      * @var HTTP_Request2_Response $response 
  50.      */
  51.     protected $response = '';
  52.  
  53.     // }}}
  54.     // __construct() {{{
  55.  
  56.     /**
  57.      * Constructor.
  58.      *
  59.      * @param string                 $msg  Error message
  60.      * @param mixed                  $code Error code or parent exception
  61.      * @param string                 $call API call that generated error
  62.      * @param HTTP_Request2_Response $resp The HTTP response instance
  63.      *
  64.      * @see Services_Twitter_Exception::$call
  65.      * @see Services_Twitter_Exception::$response
  66.      * @link http://php.net/exceptions
  67.      */
  68.     public function __construct($msg = null$code = 0$call = null$resp = null)
  69.     {
  70.         parent::__construct($msg$code);
  71.         $this->call     = $call;
  72.         $this->response = $resp;
  73.     }
  74.  
  75.     // }}}
  76.     // getCall() {{{
  77.  
  78.     /**
  79.      * Return API call
  80.      *
  81.      * @return string 
  82.      * @see Services_Twitter_Exception::$call
  83.      */
  84.     public function getCall()
  85.     {
  86.         return $this->call;
  87.     }
  88.  
  89.     // }}}
  90.     // getResponse() {{{
  91.  
  92.     /**
  93.      * Get the API HTTP response.
  94.      *
  95.      * @return HTTP_Request2_Response 
  96.      * @see Services_Twitter_Exception::$response
  97.      */
  98.     public function getResponse()
  99.     {
  100.         return $this->response;
  101.     }
  102.  
  103.     // }}}
  104.     // __toString() {{{
  105.  
  106.     /**
  107.      * __toString
  108.      *
  109.      * Overload PEAR_Exception's horrible __toString implementation.
  110.      *
  111.      * @return      string 
  112.      */
  113.     public function __toString()
  114.     {
  115.         $info 'code: ' $this->code;
  116.         if ($this->call !== null{
  117.             $info .= ', call: ' $this->call;
  118.         }
  119.         return sprintf('%s (%s)'$this->message$info);
  120.     }
  121.  
  122.     // }}}
  123. }

Documentation generated on Mon, 11 Mar 2019 15:39:03 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.