3 namespace Zumba\GastonJS\Exception;
7 * Class JavascriptError
8 * @package Zumba\GastonJS\Exception
10 class JavascriptError extends ClientError {
13 * @param array $response
15 public function __construct($response) {
16 parent::__construct($response);
17 $this->message = $this->message();
21 * Get the javascript errors found during the use of the phantomjs
24 public function javascriptErrors() {
26 $errors = $this->response["error"]["args"][0];
27 foreach ($errors as $error) {
28 $jsErrors[] = new JSErrorItem($error["message"], $error["stack"]);
34 * Returns the javascript errors found
37 public function message() {
38 $error = "One or more errors were raised in the Javascript code on the page.
39 If you don't care about these errors, you can ignore them by
40 setting js_errors: false in your Poltergeist configuration (see documentation for details).";
41 //TODO: add javascript errors
42 $jsErrors = $this->javascriptErrors();
43 foreach($jsErrors as $jsError){
44 $error = "$error\n$jsError";