Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| AblyException | |
0.00% |
0 / 6 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| getStatusCode | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Ably\Exceptions; |
| 3 | |
| 4 | use Ably\Models\ErrorInfo; |
| 5 | use \Exception; |
| 6 | |
| 7 | /** |
| 8 | * Generic Ably exception |
| 9 | */ |
| 10 | class AblyException extends Exception { |
| 11 | |
| 12 | /** |
| 13 | * @var ErrorInfo |
| 14 | */ |
| 15 | public $errorInfo; |
| 16 | |
| 17 | /** |
| 18 | * @param string $message Exception's error message text |
| 19 | * @param integer|null $code 5-digit Ably error code |
| 20 | * also used as a PHP exception code |
| 21 | * @see https://github.com/ably/ably-common/blob/master/protocol/errors.json |
| 22 | * @param integer|null $statusCode HTTP error code |
| 23 | */ |
| 24 | public function __construct( $message, $code = null, $statusCode = null ) { |
| 25 | parent::__construct( $message, $code ); |
| 26 | $this->errorInfo = new ErrorInfo(); |
| 27 | $this->errorInfo->message = $message; |
| 28 | $this->errorInfo->code = $code; |
| 29 | $this->errorInfo->statusCode = $statusCode; |
| 30 | } |
| 31 | |
| 32 | public function getStatusCode() { |
| 33 | return $this->errorInfo->statusCode; |
| 34 | } |
| 35 | |
| 36 | // PHP doesn't allow overriding these methods |
| 37 | |
| 38 | // public function getCode() { |
| 39 | // return $this->errorInfo->code; |
| 40 | // } |
| 41 | |
| 42 | // public function getMessage() { |
| 43 | // return $this->errorInfo->message; |
| 44 | // } |
| 45 | } |