Skip to content

Commit

Permalink
Fix Bug 506859 - Add name and constructor properties to each of the E…
Browse files Browse the repository at this point in the history
…rror constructors

Patch from Raphel Speyer
  • Loading branch information
nboyd%atg.com committed Jul 28, 2009
1 parent 55fd1ab commit 7408c3b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/org/mozilla/javascript/NativeGlobal.java
Expand Up @@ -144,20 +144,19 @@ public static void init(Context cx, Scriptable scope, boolean sealed) {
*/
for (int i = 0; i < errorMethods.length; i++) {
String name = errorMethods[i];
Scriptable errorProto = ScriptRuntime.
newObject(cx, scope, "Error",
ScriptableObject errorProto =
(ScriptableObject) ScriptRuntime.newObject(cx, scope, "Error",
ScriptRuntime.emptyArgs);
errorProto.put("name", errorProto, name);
if (sealed) {
if (errorProto instanceof ScriptableObject) {
((ScriptableObject)errorProto).sealObject();
}
}
errorProto.put("message", errorProto, "");
IdFunctionObject ctor = new IdFunctionObject(obj, FTAG,
Id_new_CommonError,
name, 1, scope);
ctor.markAsConstructor(errorProto);
errorProto.put("constructor", errorProto, ctor);
errorProto.setAttributes("constructor", ScriptableObject.DONTENUM);
if (sealed) {
errorProto.sealObject();
ctor.sealObject();
}
ctor.exportAsScopeProperty();
Expand Down

0 comments on commit 7408c3b

Please sign in to comment.