Skip to content

Commit 5509861

Browse files
committed
Replace \UnexpectedValueException with Http\Client\Exception\RequestException in Client::sendRequest and Client::sendAsyncRequest.
1 parent 771ecd6 commit 5509861

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
### Changed
66

7-
- `Client::sendRequest` now throws NetworkException on network errors.
7+
- `Client::sendRequest` now throws `Http\Client\Exception\NetworkException` on network errors.
8+
- `\UnexpectedValueException` replaced with `Http\Client\Exception\RequestException` in
9+
`Client::sendRequest` and `Client::sendAsyncRequest`
810

911

1012
## 1.5.1 - 2016-08-29

src/Client.php

+11-6
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ public function __destruct()
102102
* @throws \Http\Client\Exception\RequestException On invalid request.
103103
* @throws \InvalidArgumentException For invalid header names or values.
104104
* @throws \RuntimeException If creating the body stream fails.
105-
* @throws \UnexpectedValueException if unsupported HTTP version requested
106105
*
106+
* @since x.x \UnexpectedValueException replaced with RequestException.
107107
* @since x.x Throw NetworkException on network errors.
108108
* @since 1.0
109109
*/
@@ -149,11 +149,11 @@ public function sendRequest(RequestInterface $request)
149149
*
150150
* @return Promise
151151
*
152+
* @throws \Http\Client\Exception\RequestException On invalid request.
152153
* @throws \InvalidArgumentException For invalid header names or values.
153-
* @throws \RuntimeException If creating the body stream fails.
154-
* @throws \UnexpectedValueException If unsupported HTTP version requested
155-
* @throws Exception
154+
* @throws \RuntimeException If creating the body stream fails.
156155
*
156+
* @since x.x \UnexpectedValueException replaced with RequestException.
157157
* @since 1.0
158158
*/
159159
public function sendAsyncRequest(RequestInterface $request)
@@ -180,9 +180,9 @@ public function sendAsyncRequest(RequestInterface $request)
180180
* @param RequestInterface $request
181181
* @param ResponseBuilder $responseBuilder
182182
*
183+
* @throws \Http\Client\Exception\RequestException On invalid request.
183184
* @throws \InvalidArgumentException For invalid header names or values.
184185
* @throws \RuntimeException if can not read body
185-
* @throws \UnexpectedValueException if unsupported HTTP version requested
186186
*
187187
* @return array
188188
*/
@@ -194,7 +194,12 @@ private function createCurlOptions(RequestInterface $request, ResponseBuilder $r
194194
$options[CURLOPT_RETURNTRANSFER] = false;
195195
$options[CURLOPT_FOLLOWLOCATION] = false;
196196

197-
$options[CURLOPT_HTTP_VERSION] = $this->getProtocolVersion($request->getProtocolVersion());
197+
try {
198+
$options[CURLOPT_HTTP_VERSION]
199+
= $this->getProtocolVersion($request->getProtocolVersion());
200+
} catch (\UnexpectedValueException $e) {
201+
throw new Exception\RequestException($e->getMessage(), $request);
202+
}
198203
$options[CURLOPT_URL] = (string) $request->getUri();
199204

200205
/*

0 commit comments

Comments
 (0)