Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Networking Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

4.3 Handling Errors

Example 1 does not handle errors. Example 2 is an improved version that detects errors and prints a message.


NOTE -- This section assumes that you understand C++ exceptions. If you are unfamiliar with exceptions, see a C++ manual such as those listed in Appendix B.

Example 2: Handling errors

//1Encloses the main part of the example in a try block. If an exception is thrown from within the try block, the program exits the scope of the try block and looks for a catch clause to handle the exception.
//2Catches all Networking package and SourcePro Core exceptions that can be thrown from within the try block (all Rogue Wave exceptions are derived from RWxmsg). For more information, see the Essential Tools Module User's Guide.
//3Handles the exception by printing an error message. The member function why() is part of the RWxmsg class interface and is available for any exception that the Networking package might throw.


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.