]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - extlib/HTTP/Request2/Exception.php
neo-quitter theme from hannesmannerheim
[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  * This source file is subject to BSD 3-Clause License that is bundled\r
10  * with this package in the file LICENSE and available at the URL\r
11  * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
12  *\r
13  * @category  HTTP\r
14  * @package   HTTP_Request2\r
15  * @author    Alexey Borzov <avb@php.net>\r
16  * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
17  * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
18  * @link      http://pear.php.net/package/HTTP_Request2\r
19  */\r
20 \r
21 /**\r
22  * Base class for exceptions in PEAR\r
23  */\r
24 require_once 'PEAR/Exception.php';\r
25 \r
26 /**\r
27  * Base exception class for HTTP_Request2 package\r
28  *\r
29  * @category HTTP\r
30  * @package  HTTP_Request2\r
31  * @author   Alexey Borzov <avb@php.net>\r
32  * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
33  * @version  Release: 2.2.1\r
34  * @link     http://pear.php.net/package/HTTP_Request2\r
35  * @link     http://pear.php.net/pepr/pepr-proposal-show.php?id=132\r
36  */\r
37 class HTTP_Request2_Exception extends PEAR_Exception\r
38 {\r
39     /** An invalid argument was passed to a method */\r
40     const INVALID_ARGUMENT   = 1;\r
41     /** Some required value was not available */\r
42     const MISSING_VALUE      = 2;\r
43     /** Request cannot be processed due to errors in PHP configuration */\r
44     const MISCONFIGURATION   = 3;\r
45     /** Error reading the local file */\r
46     const READ_ERROR         = 4;\r
47 \r
48     /** Server returned a response that does not conform to HTTP protocol */\r
49     const MALFORMED_RESPONSE = 10;\r
50     /** Failure decoding Content-Encoding or Transfer-Encoding of response */\r
51     const DECODE_ERROR       = 20;\r
52     /** Operation timed out */\r
53     const TIMEOUT            = 30;\r
54     /** Number of redirects exceeded 'max_redirects' configuration parameter */\r
55     const TOO_MANY_REDIRECTS = 40;\r
56     /** Redirect to a protocol other than http(s):// */\r
57     const NON_HTTP_REDIRECT  = 50;\r
58 \r
59     /**\r
60      * Native error code\r
61      * @var int\r
62      */\r
63     private $_nativeCode;\r
64 \r
65     /**\r
66      * Constructor, can set package error code and native error code\r
67      *\r
68      * @param string $message    exception message\r
69      * @param int    $code       package error code, one of class constants\r
70      * @param int    $nativeCode error code from underlying PHP extension\r
71      */\r
72     public function __construct($message = null, $code = null, $nativeCode = null)\r
73     {\r
74         parent::__construct($message, $code);\r
75         $this->_nativeCode = $nativeCode;\r
76     }\r
77 \r
78     /**\r
79      * Returns error code produced by underlying PHP extension\r
80      *\r
81      * For Socket Adapter this may contain error number returned by\r
82      * stream_socket_client(), for Curl Adapter this will contain error number\r
83      * returned by curl_errno()\r
84      *\r
85      * @return integer\r
86      */\r
87     public function getNativeCode()\r
88     {\r
89         return $this->_nativeCode;\r
90     }\r
91 }\r
92 \r
93 /**\r
94  * Exception thrown in case of missing features\r
95  *\r
96  * @category HTTP\r
97  * @package  HTTP_Request2\r
98  * @author   Alexey Borzov <avb@php.net>\r
99  * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
100  * @version  Release: 2.2.1\r
101  * @link     http://pear.php.net/package/HTTP_Request2\r
102  */\r
103 class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception\r
104 {\r
105 }\r
106 \r
107 /**\r
108  * Exception that represents error in the program logic\r
109  *\r
110  * This exception usually implies a programmer's error, like passing invalid\r
111  * data to methods or trying to use PHP extensions that weren't installed or\r
112  * enabled. Usually exceptions of this kind will be thrown before request even\r
113  * starts.\r
114  *\r
115  * The exception will usually contain a package error code.\r
116  *\r
117  * @category HTTP\r
118  * @package  HTTP_Request2\r
119  * @author   Alexey Borzov <avb@php.net>\r
120  * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
121  * @version  Release: 2.2.1\r
122  * @link     http://pear.php.net/package/HTTP_Request2\r
123  */\r
124 class HTTP_Request2_LogicException extends HTTP_Request2_Exception\r
125 {\r
126 }\r
127 \r
128 /**\r
129  * Exception thrown when connection to a web or proxy server fails\r
130  *\r
131  * The exception will not contain a package error code, but will contain\r
132  * native error code, as returned by stream_socket_client() or curl_errno().\r
133  *\r
134  * @category HTTP\r
135  * @package  HTTP_Request2\r
136  * @author   Alexey Borzov <avb@php.net>\r
137  * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
138  * @version  Release: 2.2.1\r
139  * @link     http://pear.php.net/package/HTTP_Request2\r
140  */\r
141 class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception\r
142 {\r
143 }\r
144 \r
145 /**\r
146  * Exception thrown when sending or receiving HTTP message fails\r
147  *\r
148  * The exception may contain both package error code and native error code.\r
149  *\r
150  * @category HTTP\r
151  * @package  HTTP_Request2\r
152  * @author   Alexey Borzov <avb@php.net>\r
153  * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
154  * @version  Release: 2.2.1\r
155  * @link     http://pear.php.net/package/HTTP_Request2\r
156  */\r
157 class HTTP_Request2_MessageException extends HTTP_Request2_Exception\r
158 {\r
159 }\r
160 ?>