Catching Exceptions
The parameter in the interface called CatchExceptions determines how exceptions will be handled when they occur. These are for exceptions that can be handled by the library and turned into error messages, such as a configuration file is missing. In the Win32Api this parameter is always set to true and the user must query to get the errors. However in the dot NET API this choice is left to the user. In order to understand how this parameter is used please study the code example from our actual source code below:
/// <summary>
/// Initialize the API library using the ini file given.
/// </summary>
/// <param name="configFilename">The name of the ini file.</param>
/// <returns>Success</returns>
public virtual Success Initialize(string configFilename)
{
try
{
Load(configFilename);
}
catch (Exception e)
{
if (!CatchExceptions) throw;
AddToErrorList(e);
return Success.Failed;
}
return Success.Succeeded;
}