00001
00007
00008
00009
00010
00011
00012
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
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209