error.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef error_H
00050 #define error_H
00051
00052 #include "messageStream.H"
00053
00054
00055
00056 namespace Foam
00057 {
00058
00059
00060 class error;
00061 Ostream& operator<<(Ostream&, const error&);
00062
00063
00064
00065
00066
00067
00068 class error
00069 :
00070 public std::exception,
00071 public messageStream
00072 {
00073
00074 protected:
00075
00076
00077
00078 string functionName_;
00079 string sourceFileName_;
00080 label sourceFileLineNumber_;
00081
00082 bool abort_;
00083
00084 bool throwExceptions_;
00085 OStringStream* messageStreamPtr_;
00086
00087 public:
00088
00089
00090
00091
00092 error(const string& title);
00093
00094
00095 error(const dictionary& errDict);
00096
00097
00098 error(const error& err);
00099
00100
00101
00102
00103 virtual ~error() throw();
00104
00105
00106
00107
00108 string message() const;
00109
00110 const string& functionName() const
00111 {
00112 return functionName_;
00113 }
00114
00115 const string& sourceFileName() const
00116 {
00117 return sourceFileName_;
00118 }
00119
00120 label sourceFileLineNumber() const
00121 {
00122 return sourceFileLineNumber_;
00123 }
00124
00125 void throwExceptions()
00126 {
00127 throwExceptions_ = true;
00128 }
00129
00130 void dontThrowExceptions()
00131 {
00132 throwExceptions_ = false;
00133 }
00134
00135
00136
00137 OSstream& operator()
00138 (
00139 const char* functionName,
00140 const char* sourceFileName,
00141 const int sourceFileLineNumber = 0
00142 );
00143
00144 OSstream& operator()
00145 (
00146 const string& functionName,
00147 const char* sourceFileName,
00148 const int sourceFileLineNumber = 0
00149 );
00150
00151
00152
00153 operator OSstream&();
00154
00155
00156 OSstream& operator()()
00157 {
00158 return operator OSstream&();
00159 }
00160
00161
00162 operator dictionary() const;
00163
00164
00165
00166 static void printStack(Ostream& os);
00167
00168
00169
00170 void exit(const int errNo = 1);
00171
00172
00173
00174 void abort();
00175
00176
00177
00178
00179 friend Ostream& operator<<(Ostream&, const error&);
00180 };
00181
00182
00183
00184
00185 class IOerror;
00186
00187 Ostream& operator<<(Ostream&, const IOerror&);
00188
00189
00190
00191
00192
00193
00194
00195 class IOerror
00196 :
00197 public error
00198 {
00199
00200
00201 string ioFileName_;
00202 label ioStartLineNumber_;
00203 label ioEndLineNumber_;
00204
00205
00206 public:
00207
00208
00209
00210
00211 IOerror(const string& title);
00212
00213
00214 IOerror(const dictionary& errDict);
00215
00216
00217
00218
00219 virtual ~IOerror() throw();
00220
00221
00222
00223
00224 const string& ioFileName() const
00225 {
00226 return ioFileName_;
00227 }
00228
00229 label ioStartLineNumber() const
00230 {
00231 return ioStartLineNumber_;
00232 }
00233
00234 label ioEndLineNumber() const
00235 {
00236 return ioEndLineNumber_;
00237 }
00238
00239
00240
00241 OSstream& operator()
00242 (
00243 const char* functionName,
00244 const char* sourceFileName,
00245 const int sourceFileLineNumber,
00246 const string& ioFileName,
00247 const label ioStartLineNumber = -1,
00248 const label ioEndLineNumber = -1
00249 );
00250
00251
00252
00253 OSstream& operator()
00254 (
00255 const char* functionName,
00256 const char* sourceFileName,
00257 const int sourceFileLineNumber,
00258 const IOstream&
00259 );
00260
00261
00262
00263 OSstream& operator()
00264 (
00265 const char* functionName,
00266 const char* sourceFileName,
00267 const int sourceFileLineNumber,
00268 const dictionary&
00269 );
00270
00271
00272 operator dictionary() const;
00273
00274
00275
00276 void exit(const int errNo = 1);
00277
00278
00279 void abort();
00280
00281
00282
00283
00284 friend Ostream& operator<<(Ostream&, const IOerror&);
00285 };
00286
00287
00288
00289
00290
00291 extern error FatalError;
00292 extern IOerror FatalIOError;
00293
00294
00295
00296
00297 #define FatalErrorIn(fn) FatalError(fn, __FILE__, __LINE__)
00298 #define FatalIOErrorIn(fn, ios) FatalIOError(fn, __FILE__, __LINE__, ios)
00299
00300
00301
00302 #define notImplemented(fn) \
00303 FatalErrorIn(fn) << "Not implemented" << Foam::abort(FatalError);
00304
00305
00306
00307 }
00308
00309
00310
00311 #include "errorManip.H"
00312
00313
00314
00315 #endif
00316
00317
Copyright © 2000-2009 OpenCFD Ltd