Version 1
[yaffs-website] / vendor / jcalderonzumba / gastonjs / src / Exception / BrowserError.php
1 <?php
2
3 namespace Zumba\GastonJS\Exception;
4
5
6 /**
7  * Class BrowserError
8  * @package Zumba\GastonJS\Exception
9  */
10 class BrowserError extends ClientError {
11
12   /**
13    * @param array $response
14    */
15   public function __construct($response) {
16     parent::__construct($response);
17     $this->message = $this->message();
18   }
19
20   /**
21    * Gets the name of the browser error
22    * @return string
23    */
24   public function getName() {
25     return $this->response["error"]["name"];
26   }
27
28   /**
29    * @return JSErrorItem
30    */
31   public function javascriptError() {
32     //TODO: this need to be check, i don't know yet what comes in response
33     return new JSErrorItem($this->response["error"]["args"][0], $this->response["error"]["args"][1]);
34   }
35
36   /**
37    * Returns error message
38    * TODO: check how to proper implement if we have exceptions
39    * @return string
40    */
41   public function message() {
42     return "There was an error inside the PhantomJS portion of GastonJS.\nThis is probably a bug, so please report it:\n" . $this->javascriptError();
43   }
44 }