Debian Codegraph @

rhino/src/org/mozilla/javascript/EcmaError.java

raw symbols SCIP
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 // API class
8
9 package org.mozilla.javascript;
10
11 /**
12 * The class of exceptions raised by the engine as described in
13 * ECMA edition 3. See section 15.11.6 in particular.
14 */
15 public class EcmaError extends RhinoException
16 {
17 static final long serialVersionUID = -6261226256957286699L;
18
19 private String errorName;
20 private String errorMessage;
21
22 /**
23 * Create an exception with the specified detail message.
24 *
25 * Errors internal to the JavaScript engine will simply throw a
26 * RuntimeException.
27 *
28 * @param sourceName the name of the source responsible for the error
29 * @param lineNumber the line number of the source
30 * @param columnNumber the columnNumber of the source (may be zero if
31 * unknown)
32 * @param lineSource the source of the line containing the error (may be
33 * null if unknown)
34 */
35 EcmaError(String errorName, String errorMessage,
36 String sourceName, int lineNumber,
37 String lineSource, int columnNumber)
38 {
39 recordErrorOrigin(sourceName, lineNumber, lineSource, columnNumber);
40 this.errorName = errorName;
41 this.errorMessage = errorMessage;
42 }
43
44 /**
45 * @deprecated EcmaError error instances should not be constructed
46 * explicitly since they are generated by the engine.
47 */
48 @Deprecated
49 public EcmaError(Scriptable nativeError, String sourceName,
50 int lineNumber, int columnNumber, String lineSource)
51 {
52 this("InternalError", ScriptRuntime.toString(nativeError),
53 sourceName, lineNumber, lineSource, columnNumber);
54 }
55
56 @Override
57 public String details()
58 {
59 return errorName+": "+errorMessage;
60 }
61
62 /**
63 * Gets the name of the error.
64 *
65 * ECMA edition 3 defines the following
66 * errors: EvalError, RangeError, ReferenceError,
67 * SyntaxError, TypeError, and URIError. Additional error names
68 * may be added in the future.
69 *
70 * See ECMA edition 3, 15.11.7.9.
71 *
72 * @return the name of the error.
73 */
74 public String getName()
75 {
76 return errorName;
77 }
78
79 /**
80 * Gets the message corresponding to the error.
81 *
82 * See ECMA edition 3, 15.11.7.10.
83 *
84 * @return an implementation-defined string describing the error.
85 */
86 public String getErrorMessage()
87 {
88 return errorMessage;
89 }
90
91 /**
92 * @deprecated Use {@link RhinoException#sourceName()} from the super class.
93 */
94 @Deprecated
95 public String getSourceName()
96 {
97 return sourceName();
98 }
99
100 /**
101 * @deprecated Use {@link RhinoException#lineNumber()} from the super class.
102 */
103 @Deprecated
104 public int getLineNumber()
105 {
106 return lineNumber();
107 }
108
109 /**
110 * @deprecated
111 * Use {@link RhinoException#columnNumber()} from the super class.
112 */
113 @Deprecated
114 public int getColumnNumber() {
115 return columnNumber();
116 }
117
118 /**
119 * @deprecated Use {@link RhinoException#lineSource()} from the super class.
120 */
121 @Deprecated
122 public String getLineSource() {
123 return lineSource();
124 }
125
126 /**
127 * @deprecated
128 * Always returns <b>null</b>.
129 */
130 @Deprecated
131 public Scriptable getErrorObject()
132 {
133 return null;
134 }
135 }