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.


This section assumes that you understand C++ exceptions.

Example 2: Handling errors

//1

Encloses 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.

//2

Catches 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.

//3

Handles 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 DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.