Package org.htmlunit
Class ScriptException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.htmlunit.ScriptException
-
- All Implemented Interfaces:
java.io.Serializable
public class ScriptException extends java.lang.RuntimeException
An exception that will be thrown if an error occurs during the processing of a script.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.commons.logging.Log
LOG
Logging support.private HtmlPage
page_
private java.lang.String
scriptSourceCode_
-
Constructor Summary
Constructors Constructor Description ScriptException(HtmlPage page, java.lang.Throwable throwable)
Creates an instance.ScriptException(HtmlPage page, java.lang.Throwable throwable, java.lang.String scriptSourceCode)
Creates an instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String
createPrintableStackTrace()
int
getFailingColumnNumber()
Returns the column number of the source that was executing at the time of the exception.java.lang.String
getFailingLine()
Returns the line of source that was being executed when this exception was thrown.int
getFailingLineNumber()
Returns the line number of the source that was executing at the time of the exception.private static java.lang.String
getMessageFrom(java.lang.Throwable throwable)
HtmlPage
getPage()
Gets the HTML page in which the script error occurred.
Caution: this page may be only partially parsed if the exception occurred in a script executed at parsing time.java.lang.String
getScriptSourceCode()
Returns the source code line that failed.void
printScriptStackTrace(java.io.PrintWriter writer)
Prints the script stack trace.void
printStackTrace()
Prints the stack trace to System.out.void
printStackTrace(java.io.PrintStream stream)
Prints the stack trace.void
printStackTrace(java.io.PrintWriter writer)
Prints the stack trace.
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
Logging support.
-
scriptSourceCode_
private final java.lang.String scriptSourceCode_
-
page_
private final HtmlPage page_
-
-
Constructor Detail
-
ScriptException
public ScriptException(HtmlPage page, java.lang.Throwable throwable, java.lang.String scriptSourceCode)
Creates an instance.- Parameters:
page
- the page in which the script causing this exception was executedthrowable
- the exception that was thrown from the script enginescriptSourceCode
- the code that was being executed when this exception was thrown. This may be null if the exception was not caused by execution of JavaScript.
-
ScriptException
public ScriptException(HtmlPage page, java.lang.Throwable throwable)
Creates an instance.- Parameters:
page
- the page in which the script causing this exception was executedthrowable
- the exception that was thrown from the script engine
-
-
Method Detail
-
getMessageFrom
private static java.lang.String getMessageFrom(java.lang.Throwable throwable)
-
printStackTrace
public void printStackTrace()
Prints the stack trace to System.out. If this exception contains another exception then the stack traces for both will be printed.- Overrides:
printStackTrace
in classjava.lang.Throwable
-
printStackTrace
public void printStackTrace(java.io.PrintWriter writer)
Prints the stack trace. If this exception contains another exception then the stack traces for both will be printed.- Overrides:
printStackTrace
in classjava.lang.Throwable
- Parameters:
writer
- Where the stack trace will be written
-
printStackTrace
public void printStackTrace(java.io.PrintStream stream)
Prints the stack trace. If this exception contains another exception then the stack traces for both will be printed.- Overrides:
printStackTrace
in classjava.lang.Throwable
- Parameters:
stream
- Where the stack trace will be written
-
createPrintableStackTrace
private java.lang.String createPrintableStackTrace()
-
getScriptSourceCode
public java.lang.String getScriptSourceCode()
Returns the source code line that failed.- Returns:
- the source code line that failed
-
getFailingLine
public java.lang.String getFailingLine()
Returns the line of source that was being executed when this exception was thrown.- Returns:
- the line of source or an empty string if the exception was not thrown due to the execution of a script.
-
getFailingLineNumber
public int getFailingLineNumber()
Returns the line number of the source that was executing at the time of the exception.- Returns:
- the line number or -1 if the exception was not thrown due to the execution of a script.
-
getFailingColumnNumber
public int getFailingColumnNumber()
Returns the column number of the source that was executing at the time of the exception.- Returns:
- the column number or -1 if the exception was not thrown due to the execution of a script.
-
getPage
public HtmlPage getPage()
Gets the HTML page in which the script error occurred.
Caution: this page may be only partially parsed if the exception occurred in a script executed at parsing time.- Returns:
- the page
-
printScriptStackTrace
public void printScriptStackTrace(java.io.PrintWriter writer)
Prints the script stack trace. This represents only the script calls.- Parameters:
writer
- where the stack trace will be written
-
-