Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

capiexception.h

Go to the documentation of this file.
00001 00007 /*************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 00016 #ifndef CAPIEXCEPTION_H 00017 #define CAPIEXCEPTION_H 00018 00019 #include <iostream> 00020 #include <sstream> 00021 #include <string> 00022 00023 using namespace std; 00024 00035 class CapiError 00036 { 00037 public: 00043 CapiError(string errormsg,string function_name): 00044 errormsg(errormsg),function_name(function_name) 00045 {} 00046 00052 virtual string message() 00053 { 00054 return ("CapiError: "+errormsg+" occured in "+function_name); 00055 } 00056 00057 protected: 00058 string errormsg; 00059 string function_name; 00060 }; 00061 00070 class CapiWrongState : public CapiError 00071 { 00072 public: 00078 CapiWrongState(string errormsg,string function_name): 00079 CapiError("CapiWrongstate: "+errormsg,function_name) 00080 {} 00081 00087 virtual string message() 00088 { 00089 return ("CapiWrongState: "+errormsg+" occured in "+function_name); 00090 } 00091 }; 00092 00102 class CapiMsgError : public CapiError 00103 { 00104 public: 00111 CapiMsgError(unsigned info, string errormsg ,string function_name): 00112 CapiError(errormsg,function_name),info(info) 00113 {} 00114 00120 virtual string message() 00121 { 00122 stringstream m; 00123 m << "CapiMsgError: " << errormsg << " (error code 0x" << hex << info << ") occured in " << function_name; 00124 return (m.str()); 00125 } 00126 00127 protected: 00128 unsigned info; 00129 }; 00130 00138 class CapiExternalError : public CapiError 00139 { 00140 public: 00146 CapiExternalError(string errormsg,string function_name): 00147 CapiError("CapiExternalError: "+errormsg,function_name) 00148 {} 00149 00155 virtual string message() 00156 { 00157 return ("CapiExternalError: "+errormsg+" occured in "+function_name); 00158 } 00159 }; 00160 00163 inline ostream& operator<<(ostream &s, CapiError &e) 00164 { 00165 s << e.message(); 00166 return s; 00167 } 00168 00169 #endif 00170 00171 /* History 00172 00173 $Log: capiexception.h,v $ 00174 Revision 1.1 2003/02/19 08:19:53 gernot 00175 Initial revision 00176 00177 Revision 1.9 2003/01/19 16:50:27 ghillie 00178 - removed severity in exceptions. No FATAL-automatic-exit any more. 00179 Removed many FATAL conditions, other ones are exiting now by themselves 00180 00181 Revision 1.8 2002/12/13 09:57:10 ghillie 00182 - error message formatting done by exception classes now 00183 00184 Revision 1.7 2002/12/11 13:05:34 ghillie 00185 - minor comment improvements 00186 00187 Revision 1.6 2002/12/09 15:39:01 ghillie 00188 - removed severity WARNING 00189 - exception class doesn't print error message any more 00190 00191 Revision 1.5 2002/11/29 10:24:09 ghillie 00192 - updated comments, use doxygen format now 00193 - changed some parameter names in constructor of CapiMsgError 00194 00195 Revision 1.4 2002/11/27 16:00:02 ghillie 00196 updated comments for doxygen 00197 00198 Revision 1.3 2002/11/19 15:57:18 ghillie 00199 - Added missing throw() declarations 00200 - phew. Added error handling. All exceptions are caught now. 00201 00202 Revision 1.2 2002/11/18 14:24:09 ghillie 00203 - moved global severity_t to CapiError::severity_t 00204 - added throw() declarations 00205 00206 Revision 1.1 2002/11/17 14:42:22 ghillie 00207 initial checkin 00208 00209 */

Generated on Sun Nov 28 14:37:44 2004 for CapiSuite by doxygen 1.3.8