Maanu
Maanu

Reputation: 5203

ASP and COM Error Handling

We are developing ASP based web server to run on a WIN CE device. The ASP pages use a COM component for performing the server side operations.

We have a couple of doubts about the error handling. Our doubts are

What is the best method for giving error information from a COM component to the ASP page? We are using VBScript for writing ASP
If we are going to display specific error messages like ‘Connection Timeout’ received from the COM server, what is the best mechanism to pass the error message from COM? Where can we find more information about error handling?

We are new to VBScript and we could not find much information about the topic in the net

Upvotes: 1

Views: 347

Answers (2)

Bob Johnson
Bob Johnson

Reputation: 91

Here is one approach that may work for you. Put your call to the COM object inside a sub or function, so that you can use 'On Error Resume Next' just within that scope. (Unless you are doing On Error Resume Next everywhere, which is also possibly OK, as long as you are doing lots of error checking.) Whenever you do anything that might throw an error, e.g. calling your COM object, check for an error and handle it accordingly. For example, in the case where you just want to silently log the error you could call a sub similar to this one:

Sub CheckError
    If Err Then
        WriteLog "ERROR " & Err.Number & ": " & Err.Description
        Err.Clear
    End If
End Sub 'CheckError

Or alternatively, quit, and display the Error info to the user.

Upvotes: 0

yms
yms

Reputation: 10418

COM object methods generally return an HRESULT, which contains an error code in case of failure. You can try to get this value in VB.Script by reading the property Err.Number.

Upvotes: 2

Related Questions