Class NashornException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.openjdk.nashorn.api.scripting.NashornException
- All Implemented Interfaces:
Serializable
This is base exception for all Nashorn exceptions. These originate from
user's ECMAScript code. Example: script parse errors, exceptions thrown from
scripts. Note that ScriptEngine methods like "eval", "invokeMethod",
"invokeFunction" will wrap this as ScriptException and throw it. But, there
are cases where user may need to access this exception (or implementation
defined subtype of this). For example, if java interface is implemented by a
script object or Java access to script object properties via java.util.Map
interface. In these cases, user code will get an instance of this or
implementation defined subclass.
- Since:
- 1.8u40
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNashornException(String msg, String fileName, int line, int column) Constructor to initialize error message, file name, line and column numbers.protectedNashornException(String msg, Throwable cause) Constructor to initialize error message and cause exception.protectedNashornException(String msg, Throwable cause, String fileName, int line, int column) Constructor to initialize error message, cause exception, file name, line and column numbers. -
Method Summary
Modifier and TypeMethodDescriptionfinal intGet the column for thisNashornExceptionReturn the underlying ECMA error object, if available.final StringGet the source file name for thisNashornExceptionfinal intGet the line number for thisNashornExceptionstatic StackTraceElement[]getScriptFrames(Throwable exception) Returns array javascript stack frames from the given exception object.static StringgetScriptStackString(Throwable exception) Return a formatted script stack trace string with frames information separated by '\n'protected ObjectGet the thrown object.final voidsetColumnNumber(int column) Set the column for thisNashornExceptionvoidsetEcmaError(Object ecmaError) Return the underlying ECMA error object, if available.final voidsetFileName(String fileName) Set the source file name for thisNashornExceptionfinal voidsetLineNumber(int line) Set the line number for thisNashornExceptionMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
NashornException
-
NashornException
Constructor to initialize error message, cause exception, file name, line and column numbers.- Parameters:
msg- exception messagecause- exception causefileName- file nameline- line numbercolumn- column number
-
NashornException
-
-
Method Details
-
getFileName
Get the source file name for thisNashornException- Returns:
- the file name
-
setFileName
Set the source file name for thisNashornException- Parameters:
fileName- the file name
-
getLineNumber
public final int getLineNumber()Get the line number for thisNashornException- Returns:
- the line number
-
setLineNumber
public final void setLineNumber(int line) Set the line number for thisNashornException- Parameters:
line- the line number
-
getColumnNumber
public final int getColumnNumber()Get the column for thisNashornException- Returns:
- the column number
-
setColumnNumber
public final void setColumnNumber(int column) Set the column for thisNashornException- Parameters:
column- the column number
-
getScriptFrames
Returns array javascript stack frames from the given exception object.- Parameters:
exception- exception from which stack frames are retrieved and filtered- Returns:
- array of javascript stack frames
-
getScriptStackString
-
getThrown
-
getEcmaError
Return the underlying ECMA error object, if available.- Returns:
- underlying ECMA Error object's mirror or whatever was thrown from script such as a String, Number or a Boolean.
-
setEcmaError
Return the underlying ECMA error object, if available.- Parameters:
ecmaError- underlying ECMA Error object's mirror or whatever was thrown from script such as a String, Number or a Boolean.
-