src/jdk/nashorn/api/scripting/NashornException.java
Print this page
@@ -43,15 +43,15 @@
* implementation defined subclass.
*/
@SuppressWarnings("serial")
public abstract class NashornException extends RuntimeException {
// script file name
- private final String fileName;
+ private String fileName;
// script line number
- private final int line;
+ private int line;
// script column number
- private final int column;
+ private int column;
// underlying ECMA error object - lazily initialized
private Object ecmaError;
/** script source name used for "engine.js" */
public static final String ENGINE_SCRIPT_SOURCE_NAME = "nashorn:engine/resources/engine.js";
@@ -123,28 +123,55 @@
public final String getFileName() {
return fileName;
}
/**
+ * Set the source file name for this {@code NashornException}
+ *
+ * @param fileName the file name
+ */
+ public final void setFileName(final String fileName) {
+ this.fileName = fileName;
+ }
+
+ /**
* Get the line number for this {@code NashornException}
*
* @return the line number
*/
public final int getLineNumber() {
return line;
}
/**
+ * Set the line number for this {@code NashornException}
+ *
+ * @param line the line number
+ */
+ public final void setLineNumber(final int line) {
+ this.line = line;
+ }
+
+ /**
* Get the column for this {@code NashornException}
*
- * @return the column
+ * @return the column number
*/
public final int getColumnNumber() {
return column;
}
/**
+ * Set the column for this {@code NashornException}
+ *
+ * @param column the column number
+ */
+ public final void setColumnNumber(final int column) {
+ this.column = column;
+ }
+
+ /**
* Returns array javascript stack frames from the given exception object.
*
* @param exception exception from which stack frames are retrieved and filtered
* @return array of javascript stack frames
*/
@@ -206,13 +233,13 @@
return this; // initialized already!
}
final Object thrown = getThrown();
if (thrown instanceof ScriptObject) {
- ecmaError = ScriptObjectMirror.wrap(thrown, global);
+ setEcmaError(ScriptObjectMirror.wrap(thrown, global));
} else {
- ecmaError = thrown;
+ setEcmaError(thrown);
}
return this;
}
@@ -223,6 +250,16 @@
* from script such as a String, Number or a Boolean.
*/
public Object getEcmaError() {
return ecmaError;
}
+
+ /**
+ * Return the underlying ECMA error object, if available.
+ *
+ * @param ecmaError underlying ECMA Error object's mirror or whatever was thrown
+ * from script such as a String, Number or a Boolean.
+ */
+ public void setEcmaError(final Object ecmaError) {
+ this.ecmaError = ecmaError;
+ }
}