MCPcopy Create free account
hub / github.com/mozilla/rhino / NativeError

Class NativeError

rhino/src/main/java/org/mozilla/javascript/NativeError.java:23–424  ·  view source on GitHub ↗

The class of error objects ECMA 15.11

Source from the content-addressed store, hash-verified

21 * <p>ECMA 15.11
22 */
23final class NativeError extends ScriptableObject {
24 @Serial private static final long serialVersionUID = -5338413581437645187L;
25
26 private static final String ERROR_TAG = "Error";
27 private static final String STACK_TAG = "stack";
28
29 /** Default stack limit is set to "Infinity", here represented as a negative int */
30 public static final int DEFAULT_STACK_LIMIT = -1;
31
32 // This is used by "captureStackTrace"
33 private static final String STACK_HIDE_KEY = "_stackHide";
34
35 private RhinoException stackProvider;
36 private Object stack;
37
38 private static final ClassDescriptor DESCRIPTOR;
39
40 static {
41 DESCRIPTOR =
42 new ClassDescriptor.Builder(
43 ERROR_TAG,
44 1,
45 NativeError::js_constructor,
46 NativeError::js_constructor)
47 .withMethod(CTOR, "captureStackTrace", 0, NativeError::js_captureStackTrace)
48 .withMethod(CTOR, "isError", 1, NativeError::js_isError)
49 .withMethod(PROTO, "toString", 0, NativeError::js_toString)
50 .withMethod(PROTO, "toSource", 0, NativeError::js_toSource)
51 .withProp(PROTO, "name", value("Error", DONTENUM))
52 .withProp(PROTO, "message", value("", DONTENUM))
53 .withProp(PROTO, "fileName", value("", DONTENUM))
54 .withProp(PROTO, "lineNumber", value(0, DONTENUM))
55 .build();
56 }
57
58 static Object js_constructor(
59 Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args) {
60 return make(cx, f, nt, s, thisObj, args, TopLevel.NativeErrors.Error);
61 }
62
63 private static Object js_toString(
64 Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args) {
65 return js_toString((Scriptable) thisObj);
66 }
67
68 private static Object js_toSource(
69 Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args) {
70 return js_toSource(cx, s, (Scriptable) thisObj);
71 }
72
73 private static Object js_captureStackTrace(
74 Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args) {
75 js_captureStackTrace(cx, f.getDeclarationScope(), thisObj, args);
76 return Undefined.instance;
77 }
78
79 private static Object js_isError(
80 Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args) {

Callers

nothing calls this directly

Calls 4

withPropMethod · 0.80
withMethodMethod · 0.80
buildMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected