view vendor/jcalderonzumba/gastonjs/src/Exception/BrowserError.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
line wrap: on
line source
<?php

namespace Zumba\GastonJS\Exception;


/**
 * Class BrowserError
 * @package Zumba\GastonJS\Exception
 */
class BrowserError extends ClientError {

  /**
   * @param array $response
   */
  public function __construct($response) {
    parent::__construct($response);
    $this->message = $this->message();
  }

  /**
   * Gets the name of the browser error
   * @return string
   */
  public function getName() {
    return $this->response["error"]["name"];
  }

  /**
   * @return JSErrorItem
   */
  public function javascriptError() {
    //TODO: this need to be check, i don't know yet what comes in response
    return new JSErrorItem($this->response["error"]["args"][0], $this->response["error"]["args"][1]);
  }

  /**
   * Returns error message
   * TODO: check how to proper implement if we have exceptions
   * @return string
   */
  public function message() {
    return "There was an error inside the PhantomJS portion of GastonJS.\nThis is probably a bug, so please report it:\n" . $this->javascriptError();
  }
}