rwlogo
HydraExpress 4.6

HydraExpress C++ API Reference Guide


   


Rogue Wave web site:  Home Page  |  Main Documentation Page

rwsf::Exception Class Reference
[Exceptions]

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

List of all members.

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 ()
Exceptionoperator= (const Exception &m)
virtual bool operator== (const Exception exc2)
virtual bool operator!= (const Exception exc2)
virtual const char * what () const throw ()
const char * getFileName () const
const char * getFunctionName () const
unsigned long getLineNumber () const
virtual void raise (void) const
virtual Exceptionclone (void) const

Related Functions

(Note that these are not member functions.)



 RWSF_DECLARE_EXCEPTION_METHODS(className)
 RWSF_DEFINE_EXCEPTION_METHODS(className)
 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(),
             e.getFunctionName(), e.getLineNumber());
     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;
     throw rwsf::Exception(RWSF_EINFO, msg);
   }

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.

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.

Reimplemented in rwsf::XmlParseLineColException.

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]

Throws self. Overridden in derived classes to throw the correct derived type.

Reimplemented in rwsf::XmlParseException, and rwsf::XmlParseLineColException.

virtual const char* rwsf::Exception::what (  )  const throw () [virtual]

Returns a char* containing the exception message.


Friends And Related Function Documentation

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
RWSF_DEFINE_EXCEPTION_METHODS ( className   )  [related]

Throws a copy of self. Creates a new instance of self on the heap and returns the pointer to the user. The user is responsible for deallocating the associated memory.

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
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 © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.