Error Handling

<< Click to Display Table of Contents >>

Navigation:  Apollo VCL Components > Technical Information >

Error Handling

Apollo VCL supports error handling similarly to TTable component. Instead of using EDatabaseError, use EApolloError, or do not specify the exception class name at all.

 

For example, to trap a failed opening of a table because it is missing, corrupt, or locked by another user, the following code would typically be used in TTable:

 

try 

 Open;  

except on EDatabaseError do  

 Exit; 

end; 

 

Under Apollo VCL, you just change the EDatabaseError class to EApolloError as follows:

 

try 

 Open; 

except on EApolloError do // Apollo Error object specified

 Exit; 

end; 

 

Or keep it simple and raise a slilent except that quitely exits the routine:

 

try 

 Open;  

except // No error object specified

 Exit; 

end; 

 

 

You can also set the level of error reporting by calling the TApolloEnv.ErrorLevel method.

 

You can also define your own custom callback function using TApolloEnv.SetErrorFunc. The function you define will be executed when any engine level error occurs, allowing you to handle them in the way that is best for your application, and from one central place in your entire application. See the Delphi-compatible ErrFunc sample project under the ..\VCL\Samples\Delphi\ErrFunc directory for details.

 

See Also

ErrorLevel, SetErrorFunc