9 #ifndef STK_UTIL_ENVIRONMENT_REPORTHANDLER_HPP
10 #define STK_UTIL_ENVIRONMENT_REPORTHANDLER_HPP
16 namespace stk_classic {
28 typedef void (*
REH)(
const char *message,
int type);
36 typedef void (*
ErrorHandler)(
const char* expr,
const std::string& location, std::ostringstream& message);
71 void report(
const char *message,
int type);
89 const std::string& location,
90 std::ostringstream& message);
97 const std::string& location,
98 std::ostringstream& message);
105 const std::string& location,
106 std::ostringstream& message);
133 const std::string& location,
134 std::ostringstream& message);
140 const std::string& location,
141 std::ostringstream& message);
147 const std::string& location,
148 std::ostringstream& message);
169 #define XSTR_TRACE_LINE(s) STR_TRACE_LINE(s)
170 #define STR_TRACE_LINE(s) #s
172 #ifdef __PRETTY_FUNCTION__
174 #define COUT_TRACE " Function::Line="<<__PRETTY_FUNCTION__<<":"<<__LINE__
175 #define STR_TRACE (std::string(__FILE__) + ":" + XSTR_TRACE_LINE(__LINE__) + " in " + std::string(__PRETTY_FUNCTION__))
179 #define COUT_TRACE " File::Line="<<__FILE__<<":"<<__LINE__
180 #define STR_TRACE (std::string(__FILE__) + ":" + XSTR_TRACE_LINE(__LINE__))
184 #define StackTrace std::string(std::string(" exception thrown from ") + stk_classic::source_relative_path(STR_TRACE))
194 #define ThrowGenericCond(expr, message, handler) \
197 std::ostringstream stk_util_internal_throw_require_oss; \
198 stk_util_internal_throw_require_oss << message; \
199 stk_classic::handler( #expr, \
201 stk_util_internal_throw_require_oss ); \
208 #define ThrowGeneric(message, handler) \
210 std::ostringstream stk_util_internal_throw_require_oss; \
211 stk_util_internal_throw_require_oss << message; \
212 stk_classic::handler( "", \
214 stk_util_internal_throw_require_oss ); \
269 #define ThrowRequireMsg(expr,message) ThrowGenericCond(expr, message, handle_assert)
270 #define ThrowRequire(expr) ThrowRequireMsg(expr, "")
273 # define ThrowAssert(expr) ((void) (0))
274 # define ThrowAssertMsg(expr,message) ((void) (0))
276 # define ThrowAssert(expr) ThrowRequire(expr)
277 # define ThrowAssertMsg(expr,message) ThrowRequireMsg(expr,message)
280 #define ThrowErrorMsgIf(expr, message) ThrowGenericCond( !(expr), message, handle_error)
281 #define ThrowErrorIf(expr) ThrowErrorMsgIf(expr, "")
282 #define ThrowErrorMsg(message) ThrowGeneric( message, handle_error )
284 #define ThrowInvalidArgMsgIf(expr, message) ThrowGenericCond( !(expr), message, handle_invalid_arg)
285 #define ThrowInvalidArgIf(expr) ThrowInvalidArgMsgIf(expr, "")
291 #endif // STK_UTIL_ENVIRONMENT_REPORTHANDLER_HPP
ErrorHandler set_assert_handler(ErrorHandler handler)
void handle_error(const char *expr, const std::string &location, std::ostringstream &message)
void(* REH)(const char *message, int type)
Type definition REH is a pointer to a function of type void that takes a const std::exception referen...
ErrorHandler set_error_handler(ErrorHandler handler)
void handle_invalid_arg(const char *expr, const std::string &location, std::ostringstream &message)
void report(const char *message, int type)
Function report calls the current exception reporter to report the message in x.
void default_error_handler(const char *expr, const std::string &location, std::ostringstream &message)
void default_invalid_arg_handler(const char *expr, const std::string &location, std::ostringstream &message)
void(* ErrorHandler)(const char *expr, const std::string &location, std::ostringstream &message)
ErrorHandler defines the signature of functions that can be used to handle errors. expr is the expression of the failing error-check, location is a raw code location (something like file:line, no prose), and message is the error message.
void default_assert_handler(const char *expr, const std::string &location, std::ostringstream &message)
void handle_assert(const char *expr, const std::string &location, std::ostringstream &message)
REH set_report_handler(REH reh)
Function set_report_handler sets the exception report function to be called when an report_exception(...
void default_report_handler(const char *message, int type)
Function default_report_handler is the default error reporter for sierra exceptions. Note that it is implemented in Fmwk_sierra.C so that it can participate.
std::string source_relative_path(const std::string &path)
Function source_relative_path strips everything through "/src/", "/include/", "/App_"...
ErrorHandler set_invalid_arg_handler(ErrorHandler handler)