Skip to content

Commit 5748a8c

Browse files
committed
Error handling when webdriver not running
1 parent b754595 commit 5748a8c

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

lib/WebDriver/AbstractWebDriver.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
203203

204204
$httpCode = $info['http_code'];
205205

206+
if ($httpCode === 0) {
207+
throw WebDriverException::factory(
208+
WebDriverException::CURL_EXEC,
209+
$info['error']
210+
);
211+
}
212+
206213
// According to https://w3c.github.io/webdriver/webdriver-spec.html all 4xx responses are to be considered
207214
// an error and return plaintext, while 5xx responses are json encoded
208215
if ($httpCode >= 400 && $httpCode <= 499) {

lib/WebDriver/Service/CurlService.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions
116116

117117
$info = curl_getinfo($curl);
118118
$info['request_method'] = $requestMethod;
119+
$info['errno'] = curl_errno($curl);
120+
$info['error'] = curl_error($curl);
119121

120122
if (
121123
array_key_exists(CURLOPT_FAILONERROR, $extraOptions) &&

0 commit comments

Comments
 (0)