17 #include "gcp/util/common/ErrHandler.h"
18 #include "gcp/util/common/FunctionName.h"
19 #include "gcp/util/common/Directives.h"
20 #include "gcp/util/common/IoLock.h"
21 #include "gcp/util/common/Logger.h"
41 Exception(std::string str,
const char * filename,
42 const int lineNumber,
bool report);
51 Exception(std::ostringstream& os,
const char * filename,
52 const int lineNumber,
bool report);
58 const char* filename,
const int lineNumber,
bool report);
64 const char* filename,
const int lineNumber,
bool report);
84 inline void report(std::string& what)
86 gcp::util::IoLock::lockCerr();
88 gcp::util::IoLock::unlockCerr();
98 gcp::util::IoLock::lockCerr();
100 gcp::util::IoLock::unlockCerr();
103 inline const char* what() {
104 return message_.c_str();
109 std::string message_;
116 #define Error(x) gcp::util::Exception((x), __FILE__, __LINE__, true)
117 #define ErrorNoReport(x) gcp::util::Exception((x), __FILE__, __LINE__, false)
118 #define ErrorDef(x,y) gcp::util::Exception (x)((y), __FILE__, __LINE__, true)
124 #define ThrowError(text) \
126 std::ostringstream _macroOs; \
128 gcp::util::ErrHandler::throwError(_macroOs, __FILE__, __LINE__, \
129 gcp::util::FunctionName::noArgs(__PRETTY_FUNCTION__).c_str(), \
130 true, false, false);\
133 #ifdef ThrowSimpleError
134 #undef ThrowSimpleError
137 #define ThrowSimpleError(text) \
139 std::ostringstream _macroOs; \
141 gcp::util::ErrHandler::throwError(_macroOs, __FILE__, __LINE__, \
142 gcp::util::FunctionName::noArgs(__PRETTY_FUNCTION__).c_str(), \
150 #define ThrowSysError(text) \
152 std::ostringstream _macroOs; \
154 gcp::util::ErrHandler::throwError(_macroOs, __FILE__, __LINE__, \
155 gcp::util::FunctionName::noArgs(__PRETTY_FUNCTION__).c_str(), \
163 #define ReportError(text) \
165 std::ostringstream _macroOs; \
167 gcp::util::ErrHandler::report(_macroOs, __FILE__, __LINE__, \
168 gcp::util::FunctionName::noArgs(__PRETTY_FUNCTION__).c_str(), \
169 true, false, false);\
172 #ifdef ReportSimpleError
173 #undef ReportSimpleError
176 #define ReportSimpleError(text) \
178 std::ostringstream _macroOs; \
180 gcp::util::ErrHandler::report(_macroOs, __FILE__, __LINE__, \
181 gcp::util::FunctionName::noArgs(__PRETTY_FUNCTION__).c_str(), \
185 #ifdef ReportSysError
186 #undef ReportSysError
189 #define ReportSysError(text) \
191 std::ostringstream _macroOs; \
193 gcp::util::ErrHandler::report(_macroOs, __FILE__, __LINE__, \
194 gcp::util::FunctionName::noArgs(__PRETTY_FUNCTION__).c_str(), \
198 #ifdef ReportSimpleSysError
199 #undef ReportSimpleSysError
202 #define ReportSimpleSysError(text) \
204 std::ostringstream _macroOs; \
206 gcp::util::ErrHandler::report(_macroOs, __FILE__, __LINE__, \
207 gcp::util::FunctionName::noArgs(__PRETTY_FUNCTION__).c_str(), \
215 #define ReportMessage(text) \
217 std::ostringstream _macroOs; \
219 gcp::util::ErrHandler::report(_macroOs, __FILE__, __LINE__, \
220 gcp::util::FunctionName::noArgs(__PRETTY_FUNCTION__).c_str(), \
221 false, true, false);\
228 #define LogMessage(error, text) \
230 std::ostringstream _macroOs; \
232 gcp::util::ErrHandler::log(_macroOs, __FILE__, __LINE__, \
233 gcp::util::FunctionName::noArgs(__PRETTY_FUNCTION__).c_str(), \
234 false, true, false);\
237 #define COUT(statement) \
239 std::ostringstream _macroOs; \
240 _macroOs << statement << std::endl; \
241 gcp::util::Logger::printToStdout(_macroOs.str()); \
244 #define CTOUT(statement) \
246 gcp::util::TimeVal _macroTimeVal;\
247 _macroTimeVal.setToCurrentTime();\
248 std::ostringstream _macroOs; \
249 _macroOs << _macroTimeVal << ": " << statement << std::endl; \
250 gcp::util::Logger::printToStdout(_macroOs.str()); \
253 #define CERR(statement) \
255 std::ostringstream _macroOs; \
256 _macroOs << statement << std::endl; \
257 gcp::util::Logger::printToStderr(_macroOs.str()); \
260 #define CTERR(statement) \
262 gcp::util::TimeVal _macroTimeVal;\
263 _macroTimeVal.setToCurrentTime();\
264 std::ostringstream _macroOs; \
265 _macroOs << _macroTimeVal << ": " << statement << std::endl; \
266 gcp::util::Logger::printToStderr(_macroOs.str()); \
void report(std::string &what)
Definition: Exception.h:84
Definition: LogStream.h:21
Exception(std::string str, const char *filename, const int lineNumber, bool report)
virtual ~Exception()
Definition: Exception.cc:90
void report()
Definition: Exception.h:77
void report(std::string what)
Definition: Exception.h:96
Definition: Exception.h:30