9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.nashorn.internal.runtime;
27
28 import jdk.nashorn.api.scripting.NashornException;
29 import jdk.nashorn.internal.parser.Token;
30
31 /**
32 * ECMAScript parser exceptions.
33 */
34 @SuppressWarnings("serial")
35 public final class ParserException extends NashornException {
36 // Source from which this ParserException originated
37 private final Source source;
38 // token responsible for this exception
39 private final long token;
40 // if this is traslated as ECMA error, which type should be used?
41 private final JSErrorType errorType;
42
43 /**
44 * Constructor
45 *
46 * @param msg exception message for this parser error.
47 */
48 public ParserException(final String msg) {
93
94 /**
95 * Get the {@code JSErrorType} of this {@code ParserException}
96 * @return error type
97 */
98 public JSErrorType getErrorType() {
99 return errorType;
100 }
101
102 /**
103 * Throw this {@code ParserException} as one of the 7 native JavaScript errors
104 */
105 public void throwAsEcmaException() {
106 throw ECMAErrors.asEcmaException(this);
107 }
108
109 /**
110 * Throw this {@code ParserException} as one of the 7 native JavaScript errors
111 * @param global global scope object
112 */
113 public void throwAsEcmaException(final ScriptObject global) {
114 throw ECMAErrors.asEcmaException(global, this);
115 }
116 }
117
|
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.nashorn.internal.runtime;
27
28 import jdk.nashorn.api.scripting.NashornException;
29 import jdk.nashorn.internal.objects.Global;
30 import jdk.nashorn.internal.parser.Token;
31
32 /**
33 * ECMAScript parser exceptions.
34 */
35 @SuppressWarnings("serial")
36 public final class ParserException extends NashornException {
37 // Source from which this ParserException originated
38 private final Source source;
39 // token responsible for this exception
40 private final long token;
41 // if this is traslated as ECMA error, which type should be used?
42 private final JSErrorType errorType;
43
44 /**
45 * Constructor
46 *
47 * @param msg exception message for this parser error.
48 */
49 public ParserException(final String msg) {
94
95 /**
96 * Get the {@code JSErrorType} of this {@code ParserException}
97 * @return error type
98 */
99 public JSErrorType getErrorType() {
100 return errorType;
101 }
102
103 /**
104 * Throw this {@code ParserException} as one of the 7 native JavaScript errors
105 */
106 public void throwAsEcmaException() {
107 throw ECMAErrors.asEcmaException(this);
108 }
109
110 /**
111 * Throw this {@code ParserException} as one of the 7 native JavaScript errors
112 * @param global global scope object
113 */
114 public void throwAsEcmaException(final Global global) {
115 throw ECMAErrors.asEcmaException(global, this);
116 }
117 }
118
|