Exception Handling |
Mathematics toolkit uses the ANSI/ISO C++ exception mechanism to report errors. The toolkit has a specialized error class that it uses to encapsulate the problem details. The exception classes provided in Foundation toolkits are listed below.
os_math_toolkit_error -represents
an error condition in Math<ToolKit>To detect and recover from errors in any Recursion Software
toolkit, you must use C++ try...catch blocks in
your code. Failure to catch an exception will result in the global function uncaught_exception()
to be invoked, usually followed by a call to terminate().
Both of these global functions are included in your compiler's C++ runtime
library, and are not part of any Recursion Software ToolKit. The call to terminate()
forces your application to abort and is unrecoverable. It is usually better to
provide your own exception handler that safely shuts down your application if an
unexpected error condition is encountered.
The following code fragment illustrates several techniques for handling errors in Recursion Software ToolKits.
try
{
os_vec_dreal_fft l_fft;
.....
.....
l_output = l_fft.forward(l_input);
}
catch ( os_math_toolkit_error& error )
{
// This will catch an error generated by a Math<ToolKit> object.
cout << "Caught error: " << error.what() << endl;
}
catch ( os_toolkit_error& error )
{
// This will catch any error generated by a Recursion Software ToolKit,
// excluding the ANSI/ISO components found in Standards<ToolKit>.
cout << "Caught error: " << error.what() << endl;
}
catch ( ... )
{
// This catch block will handle any thrown exception, although
// you are not able to query any information about it. This is
// often used as a "last resort" to keep your application from
// crashing abnormally.
}
Copyright©1994-2013 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.