Exception Handling |
All Communications <ToolKits> use the ANSI/ISO C++ exception mechanism to report errors. Each <ToolKit> has a specialized error class that it uses to encapsulate the problem details. The exception classes provided in Communications <ToolKits> are listed below.
os_io_toolkit_error |
Represents an error condition in IO<TooklKit>. |
os_streaming_toolkit_error |
Represents an error condition in Streaming<ToolKit>. |
os_file_toolkit_error |
Represents an error condition in File<ToolKit>. |
os_network_toolkit_error |
Represents an error condition in Network<ToolKit>. |
os_pipe_toolkit_error |
Represents an error condition in Pipe<ToolKit>. |
os_security_toolkit_error |
Represents an error condition in Security<ToolKit>. |
os_framework_toolkit_error |
Represents an error condition in Framework<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 causes the global function uncaught_exception()
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. Recursion Software
recommends that you 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
{
// Attempt to display a host name.
os_host host( "www.bogus.com" );
// Assume an exception was thrown - this code never executes.
cout << "host = " << host << endl;
}
catch( os_network_toolkit_error& error )
{
// This will catch an error generated by a Network<ToolKit> object.
cout << "Caught error: " << error.what() << endl;
}
catch( os_io_toolkit_error& error )
{
// This will catch an error generated by a IO<ToolKit> object.
cout << "Caught error: " << error.what() << endl;
}
catch( os_toolkit_error& error )
{
// This will catch any error generated by an Recursion Software ToolKit,
// exclusing 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-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.