/packages/zendframework/exception.php
[return to app]1
<?php
2 /**
3 * Various Zend Framework Exception classes combined into one
4 *
5 * LICENSE
6 *
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
14 *
15 * @category Zend
16 * @package Zend
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
18 * @license http://framework.zend.com/license/new-bsd New BSD License
19 */
20 class Zend_Exception extends Exception {
21 /**
22 * @var null|Exception
23 */
24 private $_previous = null;
25
26 /**
27 * Construct the exception
28 *
29 * @param string $msg
30 * @param int $code
31 * @param Exception $previous
32 * @return void
33 */
34 public function __construct($msg = '', $code = 0, Exception $previous = null) {
35 if (version_compare(PHP_VERSION, '5.3.0', '<')) {
36 parent::__construct($msg, (int) $code);
37 $this->_previous = $previous;
38 } else {
39 parent::__construct($msg, (int) $code, $previous);
40 }
41 }
42
43 /**
44 * Overloading
45 *
46 * For PHP < 5.3.0, provides access to the getPrevious() method.
47 *
48 * @param string $method
49 * @param array $args
50 * @return mixed
51 */
52 public function __call($method, array $args) {
53 if ('getprevious' == strtolower($method)) {
54 return $this->_getPrevious();
55 }
56 return null;
57 }
58
59 /**
60 * String representation of the exception
61 *
62 * @return string
63 */
64 public function __toString() {
65 if (version_compare(PHP_VERSION, '5.3.0', '<')) {
66 if (null !== ($e = $this->getPrevious())) {
67 return $e->__toString()
68 . "\n\nNext "
69 . parent::__toString();
70 }
71 }
72 return parent::__toString();
73 }
74
75 /**
76 * Returns previous Exception
77 *
78 * @return Exception|null
79 */
80 protected function _getPrevious() {
81 return $this->_previous;
82 }
83 }
84
85 /**
86 * @category Zend
87 * @package Zend_Service
88 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
89 * @license http://framework.zend.com/license/new-bsd New BSD License
90 */
91 class Zend_Service_Exception extends Zend_Exception {}
92
93 /**
94 * @category Zend
95 * @package Zend_Service
96 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
97 * @license http://framework.zend.com/license/new-bsd New BSD License
98 */
99 class Zend_Service_Amazon_Exception extends Zend_Service_Exception {}
100
101 /**
102 * @category Zend
103 * @package Zend_Service
104 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
105 * @license http://framework.zend.com/license/new-bsd New BSD License
106 */
107 class Zend_Service_Amazon_S3_Exception extends Zend_Service_Amazon_Exception {}
108
109 /**
110 * @category Zend
111 * @package Zend_Crypt
112 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
113 * @license http://framework.zend.com/license/new-bsd New BSD License
114 */
115 class Zend_Crypt_Exception extends Zend_Exception {}
116
117 /**
118 * @category Zend
119 * @package Zend_Crypt
120 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
121 * @license http://framework.zend.com/license/new-bsd New BSD License
122 */
123 class Zend_Crypt_Hmac_Exception extends Zend_Crypt_Exception {}
124
125 class Zend_Uri_Exception extends Zend_Exception {}
126
127 /**
128 * @category Zend
129 * @package Zend_Http
130 * @subpackage Client
131 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
132 * @license http://framework.zend.com/license/new-bsd New BSD License
133 */
134 class Zend_Http_Exception extends Exception {}
135
136 /**
137 * @category Zend
138 * @package Zend_Http
139 * @subpackage Client
140 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
141 * @license http://framework.zend.com/license/new-bsd New BSD License
142 */
143 class Zend_Http_Client_Exception extends Exception {}
144
145 /**
146 * @category Zend
147 * @package Zend_Http
148 * @subpackage Client_Adapter
149 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
150 * @license http://framework.zend.com/license/new-bsd New BSD License
151 */
152 class Zend_Http_Client_Adapter_Exception extends Zend_Http_Client_Exception {
153 const READ_TIMEOUT = 1000;
154 }