3 * Exception classes for HTTP_Request2 package
\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
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
22 * Base class for exceptions in PEAR
\r
24 require_once 'PEAR/Exception.php';
\r
27 * Base exception class for HTTP_Request2 package
\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
37 class HTTP_Request2_Exception extends PEAR_Exception
\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
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
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
63 private $_nativeCode;
\r
66 * Constructor, can set package error code and native error code
\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
72 public function __construct($message = null, $code = null, $nativeCode = null)
\r
74 parent::__construct($message, $code);
\r
75 $this->_nativeCode = $nativeCode;
\r
79 * Returns error code produced by underlying PHP extension
\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
87 public function getNativeCode()
\r
89 return $this->_nativeCode;
\r
94 * Exception thrown in case of missing features
\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
103 class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception
\r
108 * Exception that represents error in the program logic
\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
115 * The exception will usually contain a package error code.
\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
124 class HTTP_Request2_LogicException extends HTTP_Request2_Exception
\r
129 * Exception thrown when connection to a web or proxy server fails
\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
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
141 class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception
\r
146 * Exception thrown when sending or receiving HTTP message fails
\r
148 * The exception may contain both package error code and native error code.
\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
157 class HTTP_Request2_MessageException extends HTTP_Request2_Exception
\r