Public Member Functions | Private Attributes

ExceptionImpl< StdExcept, MessageType > Class Template Reference

Concrete template class which implements Exception's pure virtual methods. More...

#include <keyvalue/sys/exception/Exception.h>

Inheritance diagram for ExceptionImpl< StdExcept, MessageType >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

const MessagegetMessage () const
 Gets the inner Message.
const char * what () const throw ()
 Gets a C string describing the exception.
template<typename DataType >
ExceptionImploperator& (const DataType &data)
 Appends formated data to a given exception.

Private Attributes

MessageType message_
string str_

Detailed Description

template<typename StdExcept, typename MessageType>
class keyvalue::exception::ExceptionImpl< StdExcept, MessageType >

Concrete template class which implements Exception's pure virtual methods.

Parameters:
StdExcept : (template parameter) Standard exception class that this class derives from (either std::runtime_error or std::logic_error);
MessageType : (template parameter) Type of inner Message object that might be gotten by getMessage().

Member Function Documentation

const Message & getMessage (  )  const [virtual]

Gets the inner Message.

Implements Exception.

const char * what (  )  const throw () [virtual]

Gets a C string describing the exception.

Implements Exception.

ExceptionImpl< StdExcept, MessageType > & operator& ( const DataType &  data  ) 

Appends formated data to a given exception.

Recall that this class has a Message member. This method appends data to that member (see Message::operator&).

The typical use for this method is as follows:

 if (price <= 0.0)
   throw RuntimeError() & "Invalid price. Expecting a positive number. Got " & price;
Parameters:
DataType : (template parameter) The type of data to be appended. This parameter is automatically deduced by the compiler and may be ignored by the user.
exception : The exception that data should be appended to;
data : The data to be appended.
Returns:
The exception with appended data.