Skip to content

Commit 26996bc

Browse files
committed
Error handling when webdriver not running
1 parent 5fdda8f commit 26996bc

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
@@ -124,6 +124,13 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
124124

125125
$httpCode = $info['http_code'];
126126

127+
if ($httpCode === 0) {
128+
throw WebDriverException::factory(
129+
WebDriverException::CURL_EXEC,
130+
$info['error']
131+
);
132+
}
133+
127134
// According to https://w3c.github.io/webdriver/webdriver-spec.html all 4xx responses are to be considered
128135
// an error and return plaintext, while 5xx responses are json encoded
129136
if ($httpCode >= 400 && $httpCode <= 499) {

lib/WebDriver/Service/CurlService.php

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

101101
$info = curl_getinfo($curl);
102102
$info['request_method'] = $requestMethod;
103+
$info['errno'] = curl_errno($curl);
104+
$info['error'] = curl_error($curl);
103105

104106
if (array_key_exists(CURLOPT_FAILONERROR, $extraOptions) &&
105107
$extraOptions[CURLOPT_FAILONERROR] &&

0 commit comments

Comments
 (0)