Forum Moderators: open

Message Too Old, No Replies

Error Handling

How do I put a stranglehold on my errors?

         

HyperGeek

8:48 pm on Apr 15, 2003 (gmt 0)

10+ Year Member




To begin, I am fairly literate in VBScript and SQL. However, I did not have the advantage of going to school to learn my trade, I'm completely self-taught through several books that I've tethered to my skull over the past six years.

One thing I have never been able to wrap my head around is Error Handling.

Is there a way to set up some easy code to do this? I've been told it's fairly simple.

If an error comes up, I need to stop the process and display a proper error message. After I set this up, I may even set some script in there so that I get an email about the error, but I need to take small steps first.

What are the advantages of ON ERROR RESUME? When shouldn't I use it (if at all)?

Thanks in advance!

aspdaddy

9:30 pm on Apr 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi HG,

I dont think theres any standard way of error handling in VBScript, its really about handling errors specific to the app.

Generally I use openDB() and executeSQL() functions that returns true or false, so errors can be handled in the main script.

To stop execution, (for example on submitting forms) I use a sub :
errMsg( errType, badValue )
that calls response.end after display an error message using a select case on errType.

For this I wrote an enum of expected input error types like invaidDate, notAnInt, isNull etc. just to decouple error handling from the main job of programmin.

I would use ON ERROR RESUME NEXT in production code, to make sure any objects memory is released . If you use it, you could follow every line that can potentially error with something like this :

if err.number <> 0
errMsg( err.number)
err.clear
end if

Hope this helps.

markusf

12:30 am on Apr 22, 2003 (gmt 0)

10+ Year Member



If your using ASP.net there are some error handeling classes that are EXTREMELY useful you can get them to send you any error messages that occur on your site.

For asp i would advise writing a simple custom 404 message page and having IIS redirect to it. Then loop through the forms collection, the session collection and the server variables and have the contents emailed to you. You would be amazed at the thousands of errors that can get generated and you never know about them.