Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed http-client Exception #238

Merged
merged 1 commit into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/http-client/src/Adapter/CoroutineAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Swoft\App;
use Swoft\Helper\JsonHelper;
use Swoft\Http\Message\Uri\Uri;
use Swoft\HttpClient\Exception\RuntimeException;
use Swoft\HttpClient\HttpCoResult;
use Swoft\HttpClient\HttpResultInterface;
use Swoole\Coroutine;
Expand All @@ -30,7 +31,7 @@ class CoroutineAdapter implements AdapterInterface
* @param array $options
* @return HttpResultInterface
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws RuntimeException
*/
public function request(RequestInterface $request, array $options = []): HttpResultInterface
{
Expand Down Expand Up @@ -61,7 +62,7 @@ public function request(RequestInterface $request, array $options = []): HttpRes

if (null !== $client->errCode && $client->errCode !== 0) {
App::error(sprintf('HttpClient Request ERROR #%s url=%s', $client->errCode, $url));
throw new \RuntimeException(\socket_strerror($client->errCode), $client->errCode);
throw new RuntimeException(\socket_strerror($client->errCode), $client->errCode);
}

$result = new HttpCoResult(null, $client, $profileKey);
Expand Down
5 changes: 3 additions & 2 deletions src/http-client/src/Adapter/CurlAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Psr\Http\Message\RequestInterface;
use Swoft\App;
use Swoft\Helper\JsonHelper;
use Swoft\HttpClient\Exception\RuntimeException;
use Swoft\HttpClient\HttpResult;
use Swoft\HttpClient\HttpResultInterface;

Expand All @@ -25,7 +26,7 @@ class CurlAdapter implements AdapterInterface
* @param array $options
* @return HttpResultInterface
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws RuntimeException
*/
public function request(RequestInterface $request, array $options = []): HttpResultInterface
{
Expand Down Expand Up @@ -59,7 +60,7 @@ public function request(RequestInterface $request, array $options = []): HttpRes
$errorString = curl_error($resource);
if ($errorNo) {
App::error(sprintf('HttpClient Request ERROR #%s url=%s', $errorNo, $url));
throw new \RuntimeException($errorString, $errorNo);
throw new RuntimeException($errorString, $errorNo);
}

$result = new HttpResult($result);
Expand Down