Error Handling

<< Click to Display Table of Contents >>

Navigation:  Getting Started >

Error Handling

Previous pageReturn to chapter overviewNext page

Description

Error handling in ADO

Ado reports errors to client programs in 2 different ways:

Through the return value of the method/function calls

Through the errors collection on the Connection object

 

The most clear information is always in the errors collection. (Un)fortunately you can have more than one connection open in your application so Xs2Ado does not always know which connection to check.

You can tell Xs2Ado which connection is default by calling the AdoSetConnection() function and passing it the default connection as a parameter.

Everytime there is an error, Xs2Ado will try to find the connection that is related to the object whose operation caused the error, and will use the errors collection of this connection object to get the descriptions of the errors.

If you have more than one connection open in your program, it may not always be possible for Xs2Ado to know which the default connection is, because the connection may change during program execution.

The procedure that Xs2Ado uses to find the connection involved is as follows:

The first connection that is opened becomes the 'default connection'

You may set the 'default connection' by calling AdoSetConnection() and passing it a new connection

Every Ado object has an Owner access

Ado fills this owner access with:

The collection for objects from a collection

The Command/RecordSet/Connection from which a Collection is derived for collections

Xs2Ado follows this ownership tree upwards until it finds an object of type Command/RecordSet/Connection and then has the connection.

If no connection was found for some reason, Xs2Ado uses the AdoGetConnection() function to retrieve the default connection.

 

Error handling in the AdoServer classes

Whenever an error occurs in one of the Adoserver classes the Error() method of this class is called with 2 parameters: the error object and the symbolic name of the method where the error occurred.

The default behavior of this method is the same as the default behavior of the DbServer and SqlSelect classes: If there is a client registered, and the first client has an error method the error method of the client is called with the error object as a parameter.

If there are no clients or the first client has no error method the default error handler ( as set with ErrorBlock()) is called.

 

You can change the behavior of the AdoServer Error method by calling the AdoServerCallClientError function or the AdoServerCallErrorHandler function.

Please only do this when you know what you are doing....

 

See Also

AdoSetConnection(), AdoGetConnection(), AdoErrors, AdoConnection, AdoServer:Error(), AdoServerCallClientError(), AdoServerCallErrorHandler()