Added RequestException. It is thrown when request fails.

This commit is contained in:
Pereyaslov Konstantin 2014-12-07 17:22:02 +03:00 committed by Konstantin Pereyaslov
parent 66d7f46d61
commit fe2009a7fb
3 changed files with 12 additions and 1 deletions

View File

@ -16,7 +16,9 @@ class Get extends Adapter
curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_dl_timeout); curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_dl_timeout);
$response = curl_exec($ch); $response = curl_exec($ch);
curl_close($ch); curl_close($ch);
if ($response === false) {
throw new RequestException(curl_error($ch));
}
return $response; return $response;
} }
} }

View File

@ -16,6 +16,9 @@ class Post extends Adapter
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->curl_connect_timeout_ms); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->curl_connect_timeout_ms);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_dl_timeout); curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_dl_timeout);
$response = curl_exec($ch); $response = curl_exec($ch);
if ($response === false) {
throw new RequestException(curl_error($ch));
}
curl_close($ch); curl_close($ch);
return $response; return $response;

View File

@ -0,0 +1,6 @@
<?php
namespace pdt256\Shipping\RateRequest;
class RequestException extends \Exception {}