all groups > dotnet jscript > march 2004 >
You're in the

dotnet jscript

group:

JScript exception handling woe


JScript exception handling woe jmoore NO[at]SPAM kcwc.com
3/7/2004 5:25:00 PM
dotnet jscript:
I'm migrating some Javascript code written for ASP 3.0 into ASP.Net.

I'm getting a compilation error regarding throwing an Error from a
method of a javascript object.

// This works
try {
throw new Error("Standalone test Blah");
} catch(err) {
Response.Write(err.description);
}

// This fails
function aclass() {
}
aclass.prototype = new Object();
aclass.prototype.method = function() {
try {
throw new Error("Class method test Blah");
} catch(err) {
Response.Write(err.description);
}

The error I get is :

Compiler Error Message: JS1243: Non-static member 'Error' is not
accessible from a static scope


Any ideas/hints welcome.

Jim
Re: JScript exception handling woe name
3/17/2004 2:05:55 AM
I can't see any method at all.

You are walking underhand of MS attempt to
get rid of the language.

You are "migrating" from where you have never been to.

==========

Javascript == jscript ????????????







[quoted text, click to view]
RE: JScript exception handling woe miffy900
3/17/2004 9:26:12 PM
I think because when compiled, JScript.NET has a hidden entry point, which is really from "top to bottom" (the code is executed this way)
This 'entry point', is just like a "main()" function in C#, unfortunately, JScript.NET doesnt really have a written "main()" function, but by default, the 'entry point' is made static, and your 'Error' thrown is outside the static scope, as its instantiated by the 'new' operator.
Try making a new instantiation outside the scope of the 'throw' keyword and maybe that will help
AddThis Social Bookmark Button