HydraExpress™ C++ API Reference Guide

Product Documentation:
   HydraExpress C++
Documentation Home
List of all members | Public Member Functions | Related Functions
rwsf::Exception Class Reference

The base class for all exceptions in the rwsf namespace. More...

#include <rwsf/core/Exception.h>

Inheritance diagram for rwsf::Exception:
rwsf::Fault rwsf::LoggerException rwsf::MessageInfoException rwsf::NamingException rwsf::NotImplementedException rwsf::NullPointerException rwsf::OutOfBoundsException rwsf::ServiceShutdownException rwsf::ServletException rwsf::SoapFaultException rwsf::XmlException

Public Member Functions

 Exception (const ExceptionInfo &eInfo)
 
 Exception (const char *msg)
 
 Exception (const std::string &msg)
 
 Exception (const rwsf::ExceptionInfo &eInfo, const LocalizedMessage &msg)
 
 Exception (const Exception &)
 
virtual ~Exception () throw ()
 
virtual Exceptionclone (void) const
 
const char * getFileName () const
 
const char * getFunctionName () const
 
unsigned long getLineNumber () const
 
virtual bool operator!= (const Exception exc2)
 
Exceptionoperator= (const Exception &m)
 
virtual bool operator== (const Exception exc2)
 
virtual void raise (void) const
 
virtual const char * what () const throw ()
 

Related Functions

(Note that these are not member functions.)

#define RWSF_DECLARE_EXCEPTION_METHODS(className)
 
#define RWSF_DEFINE_EXCEPTION_METHODS(className)
 
#define RWSF_EINFO
 

Detailed Description

The base class for all exceptions in the rwsf namespace, rwsf::Exception derives from std::exception and can be caught as a base class. It can also be introspected for the message, and (if rwsf::ExceptionInfo is used) for the source file, function, and line the exception occurred on.

Example of catching an exception:

try {
...
} catch (const rwsf::Exception& e) {
fprintf(stderr, "Exception occurred - message: %s, file %s,
func %s, line %d\n",e.what(), e.getFileName(),
exit(EXIT_FAILURE);
}

Example of throwing an exception with a simple string:

if (somethingWentWrong == true) {
throw rwsf::Exception("Something really bad happened!");
}

Example of throwing an exception with a localized message (see rwsf::LocalizedMessage):

if (somethingWentWrong == true) {
rwsf::LocalizedMessage msg(MY_CATALOG_ID);
msg << firstParameterReplacement;
msg << secondParameterReplacement;
}

Constructor & Destructor Documentation

rwsf::Exception::Exception ( const ExceptionInfo eInfo)

Constructs a basic exception with no message. This exception reports the information provided in eInfo (file name, function, and line number).

rwsf::Exception::Exception ( const char *  msg)

Constructs a basic exception with the given message msg. This message is not localized, and any file, function, and line info will be blank (or 0).

rwsf::Exception::Exception ( const std::string &  msg)

Constructs a basic exception with the given message msg. This message is not localized, and any file, function, and line info will be blank (or 0).

rwsf::Exception::Exception ( const rwsf::ExceptionInfo eInfo,
const LocalizedMessage &  msg 
)

Constructs a basic exception with the given message msg. This exception reports the information provided in eInfo (file name, function, line number).

rwsf::Exception::Exception ( const Exception )

Copy constructor.

virtual rwsf::Exception::~Exception ( )
throw (
)
virtual

Destructor.

Member Function Documentation

virtual Exception* rwsf::Exception::clone ( void  ) const
virtual

Creates a new copy of self on the heap. Overridden in derived classes to construct an instance of the correct derived type. It is up to the user to ensure that the returned Exception object is deleted.

Reimplemented in rwsf::XmlParseLineColException, rwsf::ServletUnavailableException, rwsf::ServiceShutdownException, rwsf::XmlParseException, rwsf::NamingException, rwsf::LoggerException, rwsf::XmlParseAttributeNotFoundException, rwsf::XmlException, rwsf::OutOfBoundsException, rwsf::NotImplementedException, rwsf::NullPointerException, rwsf::XmlSchemaException, and rwsf::ServletException.

const char* rwsf::Exception::getFileName ( ) const

Returns a char* containing the file name associated with the exception when the exception was constructed. This method may return an empty string if the file name was not specified.

const char* rwsf::Exception::getFunctionName ( ) const

Returns a char* containing the function name associated with the exception when it was constructed. This method may return an empty string if the function name was not specified.

unsigned long rwsf::Exception::getLineNumber ( ) const

Returns the line number associated with the exception when it was constructed. This method returns 0 if the line number was not specified.

virtual bool rwsf::Exception::operator!= ( const Exception  exc2)
virtual

Comparison operator.

Exception& rwsf::Exception::operator= ( const Exception m)

Assignment operator. Makes self a deep copy of m.

virtual bool rwsf::Exception::operator== ( const Exception  exc2)
virtual

Comparison operator.

virtual void rwsf::Exception::raise ( void  ) const
virtual
virtual const char* rwsf::Exception::what ( ) const
throw (
)
virtual

Returns a char* containing the exception message.

Friends And Related Function Documentation

#define RWSF_DECLARE_EXCEPTION_METHODS (   className)
related

Declares the member functions raise() and clone() on derived exception classes so that they act on an appropriate derived exception class instance.

RWSF_DECLARE_EXCEPTION_METHODS() should be included in the class declaration of a derived exception class.

See also
RWSF_DEFINE_EXCEPTION_METHODS
#define RWSF_DEFINE_EXCEPTION_METHODS (   className)
related

Defines the member functions raise() and clone() on derived exception classes so that they act on an appropriate derived exception class instance.

RWSF_DEFINE_EXCEPTION_METHODS() should be included in the source file where the derived exception class is defined.

See also
RWSF_DECLARE_EXCEPTION_METHODS
#define RWSF_EINFO
related

Macro created to return system information related to section of code where an exception was thrown:

  • name of source file containing code
  • line in source file where exception was thrown
  • method in source file where exception was thrown (if supported)

Set to return information depending upon platform of the machine running the application.

Copyright © 2020 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is registered trademark of Rogue Wave Software, Inc. in the United States and other countries, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.