-
Notifications
You must be signed in to change notification settings - Fork 845
/
UnexpectedResponseException.php
51 lines (45 loc) · 1.61 KB
/
UnexpectedResponseException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php declare(strict_types=1);
namespace Facebook\WebDriver\Exception\Internal;
use Facebook\WebDriver\Exception\PhpWebDriverExceptionInterface;
/**
* Exception thrown on invalid or unexpected server response.
*/
class UnexpectedResponseException extends \RuntimeException implements PhpWebDriverExceptionInterface
{
public static function forError(string $message): self
{
return new self($message);
}
public static function forElementNotArray($response): self
{
return new self(
sprintf(
"Unexpected server response for getting an element. Expected array, but the response was: '%s'\n",
print_r($response, true)
)
);
}
public static function forJsonDecodingError(int $jsonLastError, string $rawResults): self
{
return new self(
sprintf(
"JSON decoding of remote response failed.\n" .
"Error code: %d\n" .
"The response: '%s'\n",
$jsonLastError,
$rawResults
)
);
}
public static function forCapabilitiesRetrievalError(\Exception $previousException): self
{
return new self(
sprintf(
'Existing Capabilities were not provided, and they also cannot be read from Selenium Grid'
. ' (error: "%s"). You are probably not using Selenium Grid, so to reuse the previous session,'
. ' Capabilities must be explicitly provided to createBySessionID() method.',
$previousException->getMessage()
)
);
}
}