71 setExceptionToThrown();
72 }
73
74 /**
75 * Constructor. This is called from runtime code in Nashorn to throw things like
76 * type errors.
77 *
78 * @param thrown object to be thrown
79 * @param cause Java exception that triggered this throw
80 */
81 public ECMAException(final Object thrown, final Throwable cause) {
82 super(ScriptRuntime.safeToString(thrown), cause);
83 this.thrown = thrown;
84 setExceptionToThrown();
85 }
86
87 /**
88 * Get the thrown object
89 * @return thrown object
90 */
91 public Object getThrown() {
92 return thrown;
93 }
94
95 @Override
96 public String toString() {
97 final StringBuilder sb = new StringBuilder();
98 final String fileName = getFileName();
99 final int line = getLineNumber();
100 final int column = getColumnNumber();
101
102 if (fileName != null) {
103 sb.append(fileName);
104 if (line >= 0) {
105 sb.append(':');
106 sb.append(line);
107 }
108 if (column >= 0) {
109 sb.append(':');
110 sb.append(column);
|
71 setExceptionToThrown();
72 }
73
74 /**
75 * Constructor. This is called from runtime code in Nashorn to throw things like
76 * type errors.
77 *
78 * @param thrown object to be thrown
79 * @param cause Java exception that triggered this throw
80 */
81 public ECMAException(final Object thrown, final Throwable cause) {
82 super(ScriptRuntime.safeToString(thrown), cause);
83 this.thrown = thrown;
84 setExceptionToThrown();
85 }
86
87 /**
88 * Get the thrown object
89 * @return thrown object
90 */
91 @Override
92 public Object getThrown() {
93 return thrown;
94 }
95
96 @Override
97 public String toString() {
98 final StringBuilder sb = new StringBuilder();
99 final String fileName = getFileName();
100 final int line = getLineNumber();
101 final int column = getColumnNumber();
102
103 if (fileName != null) {
104 sb.append(fileName);
105 if (line >= 0) {
106 sb.append(':');
107 sb.append(line);
108 }
109 if (column >= 0) {
110 sb.append(':');
111 sb.append(column);
|