Using the Error Reporting Classes to Handle Errors
The
RWxmsg classes may be used in your applications in a number of ways, depending on whether or not your environment enables exceptions.
The most common use of the error reporting classes is in your try-catch blocks surrounding the code that could throw an exception. For example, consider the following.
RWTRegex<char> r;
try
{
r = RWTRegex<char>(“[a-z]*”);
}
catch (RWRegexErr& e)
{
cout << e.why() << endl; }
In this example, the instantiation (and consequent pattern compilation) could result in a pattern compilation error that would be reported through an exception of type
RWRegexErr. Therefore, the instantiation is surrounded in a try-catch block that catches exceptions of type
RWRegexErr.