Customizing Error Handling |
![]() |
As described in the "Str Library Exceptions" topic, sometimes the library may throw an exception because of abnormal conditions and/or method input parameters.
To do that, the library will call either the Error or ErrorNoObject method of class Str. By default, these two methods will either raise an exception, or - if using the STR_NO_EXCEPTIONS option is turned on - abort the application.
To customize this behavior, you must define the symbol STR_USER_ERRORS. This will cause the library to avoid compiling an implementation for the two error methods.
You must implement these two elsewhere in your program or DLL. Example:
void Str::Error(StrEC ecode) const
{
// Do some processing, then raise an exception of your
// choice to terminate the offending string operation, or
// maybe even close the application.
}
void Str::ErrorNoObject(StrEC ecode)
{
// Same as Error, but this method is static
}
See also: Str conditional defines