/
UnexpectedResponseException.php
41 lines (36 loc) · 1.32 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
<?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 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()
)
);
}
}