.NET Exception Handling in Classic ASP Pages

I am making CLR calls to an MSSQL stored procedure from ASP pages. When an exception is thrown, it is logged and then returned. In this case, I need to be able to handle the exception (if possible) in the ASP page. Note that I cannot move away from classic ASP in this case; I am stuck on a legacy system for this project. Please let me know if you know how to handle exceptions in classic ASP. I appreciate the help!

Thanks Tyler

+2


a source to share


1 answer


The classic ASP code language is VBScript, so you will need to deal with the error handling capabilities of this language using the "On Error ..." construct. You need to decide whether to do a generic error handler or insert specific error handling logic for the SQL calls.

These are your error handling options:

On Error Goto 0        ' Turns off error trapping. This is most likely what you got now
On Error Resume Next   ' In case of error, simply execute next statement. Not recommended !
On Error Goto <label>  ' Go to the specified label on an Error.

      



If you use On Error Goto ... the Err object will contain information about the error. This means that you have to write something like:

On Error Goto errorHandler
' Your code here.

errorHandler:
' Handle the error somehow. Perhaps log it and redirect to a prettier error page.
Response.Write Err.Number
Response.Write Err.Description

      

+2


a source







All Articles