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

Go to the documentation of this file.
00001 /* Copyright (C) 2002, 2003, 2004, 2005 Jan Wedekind.
00002    This file is part of the recipe database application AnyMeal.
00003 
00004    AnyMeal is free software; you can redistribute it and/or modify it under
00005    the terms of the GNU GENERAL PUBLIC LICENSE as published by the Free
00006    Software Foundation; either version 3 of the License, or (at your option)
00007    any later version.
00008 
00009    AnyMeal is distributed in the hope that it will be useful, but WITHOUT ANY
00010    WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
00011    FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
00012    details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
00016 #ifndef __ERROR_HPP
00017 #define __ERROR_HPP
00018 
00019 #include <boost/shared_ptr.hpp>
00020 #include <exception>
00021 #include <stdarg.h>
00022 #include <sstream>
00023 
00024 class Error;
00025 
00027 typedef boost::shared_ptr< Error > ErrorPtr;
00028 
00054 class Error: public std::exception {
00055  public:
00057   Error(void) {}
00059   virtual ~Error(void) throw() {}
00061   Error( const Error &aError );
00063   template< typename T >
00064   std::ostream &operator<<( const T &t ) { msgStream << t; return msgStream; }
00069   std::ostream &operator<<( std::ostream& (*__pf)( std::ostream&) )
00070     { (*__pf)( msgStream ); return msgStream; }
00072   virtual const char *what(void) const throw();
00073  protected:
00075   std::ostringstream msgStream;
00078   static std::string message;
00079 };
00080 
00081 #define ERRORMACRO( condition, class, params, message )   \
00082   if ( !( condition ) ) {                                 \
00083     class _e params;                                      \
00084     _e << message;                                         \
00085     throw _e;                                              \
00086   };
00087 
00088 #endif


anymeal 0.30 - recipe management software - Make the most of your food! - © Jan Wedekind Sun Sep 14 16:01:26 2008 - GNU Free Documentation License