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