Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.ScriptException


    final Throwable cause = event.getException().getCause();
    if (cause instanceof FailingHttpStatusCodeException)
      return true;
    else if (cause instanceof ScriptException)
    {
      final ScriptException se = (ScriptException) cause;
      return se.getPage() != null; // should probably always be the case
      // but a (now fixed) bug in HtmlUnit-1.14 causes an exception during init
      // of the JavaScriptEngine and no page is available
    }
    return false;
  }
View Full Code Here


      LOG.debug("Wrapping XPathException in StepFailedException: " + e.getMessage());
      throw new StepFailedException(e.getMessage(), (Exception) e);
    }
    else if (e instanceof ScriptException)
    {
      final ScriptException se = (ScriptException) e;
      final HtmlPage page = se.getPage(); // should normally not be null but it happens in HtmlUnit 1.14 ;-(
      final StepFailedException sfe = new StepFailedException(
          "JavaScript error loading page "
              + (page != null ? page.getWebResponse().getUrl().toString() : "")
              + ": " + se.getMessage(), se);
      sfe.addDetail("javascript error", se.getMessage());
      sfe.addDetail("line", String.valueOf(se.getFailingLineNumber()));
      sfe.addDetail("javascript source", se.getScriptSourceCode());
      sfe.addDetail("failing line", se.getFailingLine());

      // the javascript call stack
      final StringWriter stringWriter = new StringWriter();
      final PrintWriter printWriter = new PrintWriter(stringWriter);
      se.printScriptStackTrace(printWriter);
      sfe.addDetail("javascript call stack", stringWriter.toString());

      throw sfe;
    }
    else if (e instanceof SocketTimeoutException)
View Full Code Here

      final Page currentPage = context.getCurrentResponse();
      if (!(this instanceof IVerificationStep) && currentPage != null && context.getConfig().isEasyAjax()) {
        currentPage.getEnclosingWindow().getThreadManager().joinAll(context.getConfig().getEasyAjaxDelay());
      }
     
      final ScriptException bgException = context.getBackgroundJSError();
      if (bgException != null) {
        handleException(bgException);
      }
    }
    catch (final Exception ex) {
View Full Code Here

                try {
                    init(webWindow, cx);
                }
                catch (final Exception e) {
                    LOG.error("Exception while initializing JavaScript for the page", e);
                    throw new ScriptException(null, e); // BUG: null is not useful.
                }

                return null;
            }
        };
View Full Code Here

                    doProcessPostponedActions();
                    return response;
                }
            }
            catch (final Exception e) {
                handleJavaScriptException(new ScriptException(htmlPage_, e, getSourceCode(cx)));
                return null;
            }
            catch (final TimeoutError e) {
                if (getWebClient().isThrowExceptionOnScriptError()) {
                    throw new RuntimeException(e);
View Full Code Here

        catch (final MalformedURLException e) {
            if (LOG.isErrorEnabled()) {
                LOG.error("Unable to build URL for script src tag [" + srcAttribute + "]");
            }
            if (client.isThrowExceptionOnScriptError()) {
                throw new ScriptException(this, e);
            }
            return JavaScriptLoadResult.NOOP;
        }

        final Script script;
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.ScriptException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.