17 #include <stk_util/diag/StringUtil.hpp> 18 #include <stk_util/diag/Trace.hpp> 19 #include <stk_util/parallel/ExceptionReport.hpp> 20 #include <stk_util/diag/Env.hpp> 33 std::ofstream *s_testErrorMessagesFile = NULL;
35 bool s_dieOnFirstWarning =
false;
36 bool s_dieOnFirstError =
false;
38 std::string s_testErrorMessagesPath;
43 test_error_messages_to_file_report_handler(
const char * message,
int type) {
45 std::string new_message(message);
46 std::string::size_type start_pos;
50 start_pos = new_message.find(
"exception thrown from");
51 if(start_pos != std::string::npos) {
52 int end_pos = new_message.find(
'\n');
53 new_message.erase(start_pos, (end_pos - start_pos) + 1);
55 start_pos = new_message.find(
"error thrown from");
56 if(start_pos != std::string::npos) {
57 int end_pos = new_message.find(
'\n');
58 new_message.erase(start_pos, (end_pos - start_pos) + 1);
60 start_pos = new_message.find(
"warning thrown from");
61 if(start_pos != std::string::npos) {
62 int end_pos = new_message.find(
'\n');
63 new_message.erase(start_pos, (end_pos - start_pos) + 1);
65 start_pos = new_message.find(
"Exception of type");
66 if(start_pos != std::string::npos) {
67 int end_pos = new_message.find(
'\n');
68 new_message.erase(start_pos, (end_pos - start_pos) + 1);
70 start_pos = new_message.find(
"with signature");
71 if(start_pos != std::string::npos) {
72 int end_pos = new_message.find(
'\n', start_pos);
73 new_message.erase(start_pos, (end_pos - start_pos) + 1);
76 *s_testErrorMessagesFile <<
"********************************************************************************" << std::endl
77 <<
word_wrap(new_message.c_str(), 80,
"** ")
78 <<
"********************************************************************************" << std::endl;
79 *s_testErrorMessagesFile <<
"===== ENDING ERROR FILE \"" << s_testErrorMessagesPath <<
"\" =====" << std::endl;
101 delete s_testErrorMessagesFile;
112 set_test_error_messages_file(
113 const std::string & test_error_messages_path)
115 s_testErrorMessagesPath = test_error_messages_path;
117 s_testErrorMessagesFile =
new std::ofstream(s_testErrorMessagesPath.c_str(), std::ios::out);
118 *s_testErrorMessagesFile <<
"===== STARTING ERROR FILE \"" << s_testErrorMessagesPath <<
"\" =====" << std::endl;
125 get_test_error_messages_file()
127 return s_testErrorMessagesFile;
131 void set_test_error_messages_die_on_first_message(std::vector<ErrorDieEnum> errorTypes) {
132 for(
unsigned int ierr=0; ierr< errorTypes.size(); ++ierr) {
133 if(errorTypes[ierr] == DIE_ON_WARN) {
134 s_dieOnFirstWarning =
true;
136 if(errorTypes[ierr] == DIE_ON_ERROR) {
137 s_dieOnFirstError =
true;
139 if(errorTypes[ierr] == DIE_ON_MESSAGE) {
140 s_dieOnFirstWarning =
true;
141 s_dieOnFirstError =
true;
149 bool get_test_error_messages_die_on_first_warning() {
150 return s_dieOnFirstWarning;
153 bool get_test_error_messages_die_on_first_error() {
154 return s_dieOnFirstError;
160 void SIERRA_FORTRAN(report_error)(
int &int_val,
const char *message,
const int message_length) {
167 sierra::RuntimeWarning() <<
"In Fmwk, " << std::string(message, message + message_length) << std::endl << WarnTrace;
171 throw sierra::RuntimeError() <<
"In Fmwk, " << std::string(message, message + message_length) << std::endl << ErrorTrace;
stk_classic::RuntimeWarningAdHoc RuntimeWarning
Deprecated.
std::ostream & outputP0()
Function outputP0 returns the processor output log stream on processor 0 and the null log stream on a...
ExTemp1< std::runtime_error > RuntimeError
Defined in <stdexcept>
Message is a fatal error.
std::string word_wrap(const std::string &s, unsigned int line_length, const std::string &prefix, const std::string &prefix_first_line)
Function word_wrap reformats a string into multiple lines, none longer that line_length, the first line prefixed with prefix_first_line and the remaining lines prefixed with prefix.
REH set_report_handler(REH reh)
Function set_report_handler sets the exception report function to be called when an report_exception(...