Source Property

See Also    Example    Applies To

Returns the name of the object or application that originally generated the error.

Syntax

CStringGetSource(VOID);

Remarks

The Source property value is usually the object's class name or programmatic ID. Use the Source property to provide your users with information when your code is unable to handle an error generated in an object in another application.

Based on all of the error documentation, you can write code that will handle the error appropriately. If your error handler fails, you can use the CdbError object information to describe the error to your user, using the Source property and the other CdbError properties to give the user information about which object originally caused the error, the description of the error, and so forth.

For example, if you access Microsoft Excel and it generates a "Division by zero" error, Microsoft Excel sets CdbError.Number to the Microsoft Excel code for that error and sets the Source property to Excel.Application. Note that if the error is generated in another object called by Microsoft Excel, Microsoft Excel intercepts the error and still sets CdbError.Number to the Microsoft Excel code. However, the other CdbError object properties (including Source) will retain the values as set by the object that generated the error. The Source property always contains the name of the object that originally generated the error.