]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - extlib/HTTP/Request2/Exception.php
b7b8d8d0379eb82417900d81f97b9276d2707db1
[quix0rs-gnu-social.git] / extlib / HTTP / Request2 / Exception.php
1 <?php\r
2 /**\r
3  * Exception classes for HTTP_Request2 package\r
4  *\r
5  * PHP version 5\r
6  *\r
7  * LICENSE:\r
8  *\r
9  * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
10  * All rights reserved.\r
11  *\r
12  * Redistribution and use in source and binary forms, with or without\r
13  * modification, are permitted provided that the following conditions\r
14  * are met:\r
15  *\r
16  *    * Redistributions of source code must retain the above copyright\r
17  *      notice, this list of conditions and the following disclaimer.\r
18  *    * Redistributions in binary form must reproduce the above copyright\r
19  *      notice, this list of conditions and the following disclaimer in the\r
20  *      documentation and/or other materials provided with the distribution.\r
21  *    * The names of the authors may not be used to endorse or promote products\r
22  *      derived from this software without specific prior written permission.\r
23  *\r
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
25  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
26  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
27  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
28  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
29  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
30  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
31  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
32  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
35  *\r
36  * @category HTTP\r
37  * @package  HTTP_Request2\r
38  * @author   Alexey Borzov <avb@php.net>\r
39  * @license  http://opensource.org/licenses/bsd-license.php New BSD License\r
40  * @version  SVN: $Id: Exception.php 324415 2012-03-21 10:50:50Z avb $\r
41  * @link     http://pear.php.net/package/HTTP_Request2\r
42  */\r
43 \r
44 /**\r
45  * Base class for exceptions in PEAR\r
46  */\r
47 require_once 'PEAR/Exception.php';\r
48 \r
49 /**\r
50  * Base exception class for HTTP_Request2 package\r
51  *\r
52  * @category HTTP\r
53  * @package  HTTP_Request2\r
54  * @author   Alexey Borzov <avb@php.net>\r
55  * @license  http://opensource.org/licenses/bsd-license.php New BSD License\r
56  * @version  Release: 2.1.1\r
57  * @link     http://pear.php.net/package/HTTP_Request2\r
58  * @link     http://pear.php.net/pepr/pepr-proposal-show.php?id=132\r
59  */\r
60 class HTTP_Request2_Exception extends PEAR_Exception\r
61 {\r
62     /** An invalid argument was passed to a method */\r
63     const INVALID_ARGUMENT   = 1;\r
64     /** Some required value was not available */\r
65     const MISSING_VALUE      = 2;\r
66     /** Request cannot be processed due to errors in PHP configuration */\r
67     const MISCONFIGURATION   = 3;\r
68     /** Error reading the local file */\r
69     const READ_ERROR         = 4;\r
70 \r
71     /** Server returned a response that does not conform to HTTP protocol */\r
72     const MALFORMED_RESPONSE = 10;\r
73     /** Failure decoding Content-Encoding or Transfer-Encoding of response */\r
74     const DECODE_ERROR       = 20;\r
75     /** Operation timed out */\r
76     const TIMEOUT            = 30;\r
77     /** Number of redirects exceeded 'max_redirects' configuration parameter */\r
78     const TOO_MANY_REDIRECTS = 40;\r
79     /** Redirect to a protocol other than http(s):// */\r
80     const NON_HTTP_REDIRECT  = 50;\r
81 \r
82     /**\r
83      * Native error code\r
84      * @var int\r
85      */\r
86     private $_nativeCode;\r
87 \r
88     /**\r
89      * Constructor, can set package error code and native error code\r
90      *\r
91      * @param string $message    exception message\r
92      * @param int    $code       package error code, one of class constants\r
93      * @param int    $nativeCode error code from underlying PHP extension\r
94      */\r
95     public function __construct($message = null, $code = null, $nativeCode = null)\r
96     {\r
97         parent::__construct($message, $code);\r
98         $this->_nativeCode = $nativeCode;\r
99     }\r
100 \r
101     /**\r
102      * Returns error code produced by underlying PHP extension\r
103      *\r
104      * For Socket Adapter this may contain error number returned by\r
105      * stream_socket_client(), for Curl Adapter this will contain error number\r
106      * returned by curl_errno()\r
107      *\r
108      * @return integer\r
109      */\r
110     public function getNativeCode()\r
111     {\r
112         return $this->_nativeCode;\r
113     }\r
114 }\r
115 \r
116 /**\r
117  * Exception thrown in case of missing features\r
118  *\r
119  * @category HTTP\r
120  * @package  HTTP_Request2\r
121  * @author   Alexey Borzov <avb@php.net>\r
122  * @license  http://opensource.org/licenses/bsd-license.php New BSD License\r
123  * @version  Release: 2.1.1\r
124  * @link     http://pear.php.net/package/HTTP_Request2\r
125  */\r
126 class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception\r
127 {\r
128 }\r
129 \r
130 /**\r
131  * Exception that represents error in the program logic\r
132  *\r
133  * This exception usually implies a programmer's error, like passing invalid\r
134  * data to methods or trying to use PHP extensions that weren't installed or\r
135  * enabled. Usually exceptions of this kind will be thrown before request even\r
136  * starts.\r
137  *\r
138  * The exception will usually contain a package error code.\r
139  *\r
140  * @category HTTP\r
141  * @package  HTTP_Request2\r
142  * @author   Alexey Borzov <avb@php.net>\r
143  * @license  http://opensource.org/licenses/bsd-license.php New BSD License\r
144  * @version  Release: 2.1.1\r
145  * @link     http://pear.php.net/package/HTTP_Request2\r
146  */\r
147 class HTTP_Request2_LogicException extends HTTP_Request2_Exception\r
148 {\r
149 }\r
150 \r
151 /**\r
152  * Exception thrown when connection to a web or proxy server fails\r
153  *\r
154  * The exception will not contain a package error code, but will contain\r
155  * native error code, as returned by stream_socket_client() or curl_errno().\r
156  *\r
157  * @category HTTP\r
158  * @package  HTTP_Request2\r
159  * @author   Alexey Borzov <avb@php.net>\r
160  * @license  http://opensource.org/licenses/bsd-license.php New BSD License\r
161  * @version  Release: 2.1.1\r
162  * @link     http://pear.php.net/package/HTTP_Request2\r
163  */\r
164 class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception\r
165 {\r
166 }\r
167 \r
168 /**\r
169  * Exception thrown when sending or receiving HTTP message fails\r
170  *\r
171  * The exception may contain both package error code and native error code.\r
172  *\r
173  * @category HTTP\r
174  * @package  HTTP_Request2\r
175  * @author   Alexey Borzov <avb@php.net>\r
176  * @license  http://opensource.org/licenses/bsd-license.php New BSD License\r
177  * @version  Release: 2.1.1\r
178  * @link     http://pear.php.net/package/HTTP_Request2\r
179  */\r
180 class HTTP_Request2_MessageException extends HTTP_Request2_Exception\r
181 {\r
182 }\r
183 ?>