try:
some code that can raise an error
except:
do error handeling stuff
finally:
clean up, close files etc
Can be emulated in vbscript as follows:
class CustomErrorHandler
private sub class_terminate
if err.number > 0 then
do error handeling stuff
end if
clean up, close files etc
end sub
end class
with new CustomErrorHandler
some code
...
end with
How does this work? The 'class_terminate' method will be called when the newly created instance goes out of scope. This happens either when the interperter hits the 'end with' statement or when the callstack gets unwinded due to an error. It's less pretty then the native python approach but it works quite well and isn't to ugly.
For top level error handling you can use the same technique. This time don't use the with statement but create a global instance of your error handler. Beware that the ASPError object provided server.getLastError() isn't the same as the vbscript err object and is only available after IIS has done its server.transfer to the 500:100 error handler and has come back to your page to collect the garbage. Example handler:
class cDebugger
public sub do_debug
' print debug data here
end sub
public sub class_terminate
if server.getlasterror().Number <> 0 then
response.clear
call do_debug
end if
end sub
end class