33namespace Kobas ;
44
55
6+ use Kobas \Exception \CurlException ;
67use Kobas \Exception \HttpException ;
78use Kobas \Auth \Signer ;
89use Kobas \Request \Curl ;
@@ -100,6 +101,7 @@ public function disableSSLVerification()
100101 * @param array $headers
101102 * @return mixed
102103 * @throws HttpException
104+ * @throws CurlException
103105 */
104106 public function get ($ route , array $ params = array (), array $ headers = array ())
105107 {
@@ -113,6 +115,7 @@ public function get($route, array $params = array(), array $headers = array())
113115 * @param array $headers
114116 * @return mixed
115117 * @throws HttpException
118+ * @throws CurlException
116119 */
117120 public function post ($ route , array $ params = array (), array $ headers = array ())
118121 {
@@ -126,6 +129,7 @@ public function post($route, array $params = array(), array $headers = array())
126129 * @param array $headers
127130 * @return mixed
128131 * @throws HttpException
132+ * @throws CurlException
129133 */
130134 public function put ($ route , array $ params = array (), array $ headers = array ())
131135 {
@@ -139,6 +143,7 @@ public function put($route, array $params = array(), array $headers = array())
139143 * @param array $headers
140144 * @return mixed
141145 * @throws HttpException
146+ * @throws CurlException
142147 */
143148 public function delete ($ route , array $ params = array (), array $ headers = array ())
144149 {
@@ -152,6 +157,7 @@ public function delete($route, array $params = array(), array $headers = array()
152157 * @param array $headers
153158 * @return mixed
154159 * @throws HttpException
160+ * @throws CurlException
155161 */
156162 protected function call ($ http_method , $ route , array $ params = array (), array $ headers = array ())
157163 {
@@ -169,7 +175,7 @@ protected function call($http_method, $route, array $params = array(), array $he
169175 ->setOption (CURLOPT_FOLLOWLOCATION , true )
170176 ->setOption (CURLOPT_ENCODING , '' );
171177
172- foreach ($ this ->curl_options as $ option => $ value ) {
178+ foreach ($ this ->curl_options as $ option => $ value ) {
173179 $ this ->request ->setOption ($ option , $ value );
174180 }
175181
@@ -203,7 +209,13 @@ protected function call($http_method, $route, array $params = array(), array $he
203209
204210 $ this ->request ->setOption (CURLOPT_HTTPHEADER , $ headers );
205211
212+
206213 $ result = $ this ->request ->execute ();
214+
215+ if ($ this ->request ->getErrorNumber ()) {
216+ throw new CurlException ($ this ->request ->getErrorMessage (), $ this ->request ->getErrorNumber ());
217+ }
218+
207219 $ last_response = $ this ->request ->getInfo (CURLINFO_HTTP_CODE );
208220
209221 $ this ->request ->close ();
0 commit comments