"finally" not executing after a re-throw
From: Peter X (peterx14_at_example.com)
Date: 11/15/04
- Next message: shel: "Unexpected error"
- Previous message: Marc Walgren: "Page Refresh problem"
- Next in thread: Peter X: "Re: "finally" not executing after a re-throw"
- Reply: Peter X: "Re: "finally" not executing after a re-throw"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 15 Nov 2004 23:13:24 +0000
Hi all,
I've got a script that may throw an exception and that needs to release
a resource if that happens. However, I don't want to "handle" the
exception, since I can't... I don't know what it is yet! So I try, I
catch and re-throw, and I release resources in the finally block.
However, under WSH, the finally block isn't being executed. Example:
try {
alert("try");
nonExistantCall();
}
catch(e) {
alert("catch e=[" + e + "]");
throw e; // Re-throw.
}
finally {
alert("finally");
}
alert("Complete!");
function alert(msg)
{
var objShell = WScript.CreateObject("WScript.shell");
objShell.Popup(msg);
}
If I save this as a .js file and click on it in Windows Explorer, I get
the "try", "catch" and the "WSH runtime error" (courtesy of the
re-throw). But no "finally" message!
The odd thing is, if I bung the same code into a web page (*without the
alert function*), then Internet Explorer will give me "try", "catch",
"finally" and *then* an Internet Explorer error.
So is JScript broken?
-- TIA! Peter.
- Next message: shel: "Unexpected error"
- Previous message: Marc Walgren: "Page Refresh problem"
- Next in thread: Peter X: "Re: "finally" not executing after a re-throw"
- Reply: Peter X: "Re: "finally" not executing after a re-throw"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|