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 #ifndef error_H
00046 #define error_H
00047
00048 #include "messageStream.H"
00049
00050
00051
00052 namespace Foam
00053 {
00054
00055
00056
00057
00058
00059 class error
00060 :
00061 public messageStream
00062 {
00063
00064 protected:
00065
00066
00067
00068 string functionName_;
00069 string sourceFileName_;
00070 label sourceFileLineNumber_;
00071
00072 bool abort_;
00073
00074 bool throwExceptions_;
00075 OStringStream* messageStreamPtr_;
00076
00077 public:
00078
00079
00080
00081
00082 error(const string& title);
00083
00084
00085 error(const dictionary& errDict);
00086
00087
00088
00089
00090 ~error();
00091
00092
00093
00094
00095 string message() const;
00096
00097 const string& functionName() const
00098 {
00099 return functionName_;
00100 }
00101
00102 const string& sourceFileName() const
00103 {
00104 return sourceFileName_;
00105 }
00106
00107 label sourceFileLineNumber() const
00108 {
00109 return sourceFileLineNumber_;
00110 }
00111
00112 void throwExceptions()
00113 {
00114 throwExceptions_ = true;
00115 }
00116
00117 void dontThrowExceptions()
00118 {
00119 throwExceptions_ = false;
00120 }
00121
00122
00123
00124 OSstream& operator()
00125 (
00126 const char* functionName,
00127 const char* sourceFileName,
00128 const int sourceFileLineNumber = 0
00129 );
00130
00131 OSstream& operator()
00132 (
00133 const string& functionName,
00134 const char* sourceFileName,
00135 const int sourceFileLineNumber = 0
00136 );
00137
00138
00139
00140 operator OSstream&();
00141
00142
00143 operator dictionary() const;
00144
00145
00146
00147 static void printStack(Ostream& os);
00148
00149
00150
00151 void exit(const int errNo = 1);
00152
00153
00154
00155 void abort();
00156
00157
00158
00159
00160 friend Ostream& operator<<(Ostream&, const error&);
00161 };
00162
00163
00164
00165
00166
00167
00168 class IOerror
00169 :
00170 public error
00171 {
00172
00173
00174 string ioFileName_;
00175 label ioStartLineNumber_;
00176 label ioEndLineNumber_;
00177
00178
00179 public:
00180
00181
00182
00183
00184 IOerror(const string& title);
00185
00186
00187 IOerror(const dictionary& errDict);
00188
00189
00190
00191
00192 const string& ioFileName() const
00193 {
00194 return ioFileName_;
00195 }
00196
00197 label ioStartLineNumber() const
00198 {
00199 return ioStartLineNumber_;
00200 }
00201
00202 label ioEndLineNumber() const
00203 {
00204 return ioEndLineNumber_;
00205 }
00206
00207
00208
00209 OSstream& operator()
00210 (
00211 const char* functionName,
00212 const char* sourceFileName,
00213 const int sourceFileLineNumber,
00214 const string& ioFileName,
00215 const label ioStartLineNumber = -1,
00216 const label ioEndLineNumber = -1
00217 );
00218
00219
00220
00221 OSstream& operator()
00222 (
00223 const char* functionName,
00224 const char* sourceFileName,
00225 const int sourceFileLineNumber,
00226 const IOstream&
00227 );
00228
00229
00230
00231 OSstream& operator()
00232 (
00233 const char* functionName,
00234 const char* sourceFileName,
00235 const int sourceFileLineNumber,
00236 const dictionary&
00237 );
00238
00239
00240 operator dictionary() const;
00241
00242
00243
00244 void exit(const int errNo = 1);
00245
00246
00247 void abort();
00248
00249
00250
00251
00252 friend Ostream& operator<<(Ostream&, const IOerror&);
00253 };
00254
00255
00256
00257
00258
00259 extern error FatalError;
00260 extern IOerror FatalIOError;
00261
00262
00263
00264
00265 #define FatalErrorIn(fn) FatalError(fn, __FILE__, __LINE__)
00266 #define FatalIOErrorIn(fn, ios) FatalIOError(fn, __FILE__, __LINE__, ios)
00267
00268
00269
00270 #define notImplemented(fn) \
00271 FatalErrorIn(fn) << "Not implemented" << Foam::abort(FatalError);
00272
00273
00274
00275 }
00276
00277
00278
00279 #include "errorManip.H"
00280
00281
00282
00283 #endif
00284
00285
Copyright © 2000-2007 OpenCFD Ltd