Main | License | Installation | FAQ | Screenshots | Contact | Links | Sf.net | Freshmeat.net | KDE-Apps.org
Requirements | Design | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

Error Class Reference

#include <error.hpp>

Inheritance diagram for Error:
Inheritance graph
[legend]

Public Member Functions

 Error (void)
 Constructor.
virtual ~Error (void) throw ()
 Error (const Error &aError)
 Copy constructor.
template<typename T >
std::ostream & operator<< (const T &t)
std::ostream & operator<< (std::ostream &(*__pf)(std::ostream &))
virtual const char * what (void) const throw ()
 Returns error message (not thread-safe).

Protected Attributes

std::ostringstream msgStream
 String containing the error message.

Static Protected Attributes

static std::string message

Detailed Description

An exception class for exception-handling. You can use the ERRORMACRO for throwing exceptions:

    void test( int i ) throw (Error)
    {
      ERRORMACRO( i > 0, Error, ,
                  "Parameter for method test must be greater than zero (but "
                  "was " << i << ")." );
    }
    
    int main(void)
    {
      try {
        test( -5 );
      } catch ( Error &e ) {
        cerr << e.what() << endl;
      };
      return 0;
    }

Mind that the macro uses a variable with the name _e. Make sure, that you don't use this variable-name in any of the macro-arguments!

Date:
Fri Apr 12 2002
Author:
Jan Wedekind (wedesoft@users.sourceforge.net)

Definition at line 54 of file error.hpp.


Constructor & Destructor Documentation

Error::Error ( void   )  [inline]

Constructor.

Definition at line 57 of file error.hpp.

00057 {}

virtual Error::~Error ( void   )  throw () [inline, virtual]

Definition at line 59 of file error.hpp.

00059 {}

Error::Error ( const Error aError  ) 

Copy constructor.

Definition at line 25 of file error.cpp.

References msgStream.

00026                                  :
00027   std::exception( _error )
00028 {
00029   msgStream << _error.msgStream.str();
}


Member Function Documentation

std::ostream& Error::operator<< ( std::ostream &(*)(std::ostream &)  __pf  )  [inline]

Interface for manipulators. Manipulators such as std::endl and std::hex use these functions in constructs like "Error e; e << std::endl". For more information, see the iomanip header.

Definition at line 69 of file error.hpp.

References msgStream.

00070     { (*__pf)( msgStream ); return msgStream; }

template<typename T >
std::ostream& Error::operator<< ( const T &  t  )  [inline]

Definition at line 64 of file error.hpp.

References msgStream.

00064 { msgStream << t; return msgStream; }

const char * Error::what ( void   )  const throw () [virtual]

Returns error message (not thread-safe).

Definition at line 31 of file error.cpp.

References message, and msgStream.

Referenced by cli(), gui(), main(), and ODBCStatement::ODBCStatement().

00032 {
00033   message = msgStream.str();
00034   return message.c_str();
00035 }


Field Documentation

string Error::message [static, protected]

Temporary string to do null-termination. The method what() requires a null-terminated string.

Reimplemented in XSLParseError.

Definition at line 78 of file error.hpp.

Referenced by what().

std::ostringstream Error::msgStream [protected]

String containing the error message.

Definition at line 75 of file error.hpp.

Referenced by Error(), operator<<(), and what().


The documentation for this class was generated from the following files:


anymeal 0.31 - recipe management software - Make the most of your food! - © Jan Wedekind Sun Dec 19 19:36:03 2010 - GNU Free Documentation License