Skip to content

Commit 034dfb6

Browse files
committed
Fix error/exception handling
1 parent f9d53f5 commit 034dfb6

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/WebDriver/AbstractWebDriver.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
228228
);
229229
}
230230

231-
if (is_array($result) && ! array_key_exists('status', $result) && ! isset($result['value']['ready']) && ! isset($result['value']['error'])) {
231+
if (is_array($result) && ! array_key_exists('status', $result) && ! array_key_exists('value', $result)) {
232232
throw WebDriverException::factory(
233233
WebDriverException::CURL_EXEC,
234234
'Payload received from webdriver is valid but unexpected json: ' . substr($rawResult, 0, 1000)
@@ -253,13 +253,6 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
253253
);
254254
}
255255

256-
if (isset($value['ready']) && $value['ready'] !== true) {
257-
throw WebDriverException::factory(
258-
WebDriverException::CURL_EXEC,
259-
$message
260-
);
261-
}
262-
263256
$sessionId = isset($result['sessionId'])
264257
? $result['sessionId']
265258
: (isset($value['webdriver.remote.sessionid'])

lib/WebDriver/Exception.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ abstract class Exception extends \Exception
8787
const UNEXPECTED_PARAMETERS = -5;
8888
const INVALID_REQUEST = -6;
8989
const UNKNOWN_LOCATOR_STRATEGY = -7;
90+
const W3C_WEBDRIVER_ERROR = -8;
9091

9192
private static $errs = array(
9293
// self::SUCCESS => array('Success', 'This should never be thrown!'),
@@ -178,6 +179,10 @@ public static function factory($code, $message = null, $previousException = null
178179
$message = $errorDefinition[1];
179180
}
180181

182+
if (! is_numeric($code)) {
183+
$code = self::W3C_WEBDRIVER_ERROR;
184+
}
185+
181186
$className = __CLASS__ . '\\' . $errorDefinition[0];
182187

183188
return new $className($message, $code, $previousException);

0 commit comments

Comments
 (0)