Thursday, April 16, 2009

vbscript error handling

Added error handling to asp file which adds content disposition attachment headers to files on stream.radiosai.org - used ideas from this msdn blog post and this devguru article to write something like:
Err.Clear
On Error Resume next
'This statement makes the program resume the next statement
'instead of throwing an error
'***************
set f=fs.GetFile(strFilePath)
strFileSize=f.Size

numerror=Err.number
if numerror <> 0 Then
Response.Write ErrorMesg
Response.Flush
else
....snip snip ....
'and at the end of the script
On Error GoTo 0
'This means On Error, report it - the syntax is crazy.

No comments:

Post a Comment