HydraExpress™ C++ API Reference Guide

 
Loading...
Searching...
No Matches
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 char *msg)
 Exception (const Exception &)
 Exception (const ExceptionInfo &eInfo)
 Exception (const rwsf::ExceptionInfo &eInfo, const LocalizedMessage &msg)
 Exception (const std::string &msg)
virtual ~Exception () noexcept
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 noexcept

Friends

class rwsf::ExceptionInfo

(Note that these are not member symbols.)

#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);
}
The base class for all exceptions in the rwsf namespace.
Definition Exception.h:102
const char * getFileName() const
virtual const char * what() const noexcept
const char * getFunctionName() const
unsigned long getLineNumber() const

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;
}
#define RWSF_EINFO
Definition ExceptionInfo.h:112

Constructor & Destructor Documentation

◆ Exception() [1/5]

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

◆ Exception() [2/5]

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

◆ Exception() [3/5]

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

◆ Exception() [4/5]

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

◆ Exception() [5/5]

rwsf::Exception::Exception ( const Exception & )

Copy constructor.

◆ ~Exception()

virtual rwsf::Exception::~Exception ( )
virtualnoexcept

Destructor.

Member Function Documentation

◆ clone()

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::LoggerException, rwsf::NamingException, rwsf::NotImplementedException, rwsf::NullPointerException, rwsf::OutOfBoundsException, rwsf::ServiceShutdownException, rwsf::ServletException, rwsf::ServletUnavailableException, rwsf::XmlException, rwsf::XmlParseAttributeNotFoundException, rwsf::XmlParseException, rwsf::XmlParseLineColException, and rwsf::XmlSchemaException.

◆ getFileName()

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.

◆ getFunctionName()

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.

◆ getLineNumber()

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.

◆ operator!=()

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

Comparison operator.

◆ operator=()

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

Assignment operator. Makes self a deep copy of m.

◆ operator==()

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

Comparison operator.

◆ raise()

◆ what()

virtual const char * rwsf::Exception::what ( ) const
virtualnoexcept

Returns a char* containing the exception message.

◆ RWSF_DECLARE_EXCEPTION_METHODS

#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

◆ 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

◆ RWSF_EINFO

#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 © 2026 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.