Improved error message printed when ct2ctml fails
Now we actually print the contents of the log file.
This commit is contained in:
parent
2fa2d98171
commit
ebc6ef1e47
1 changed files with 18 additions and 30 deletions
|
|
@ -12,11 +12,11 @@
|
||||||
#include "cantera/base/stringUtils.h"
|
#include "cantera/base/stringUtils.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
// These defines are needed for the windows Sleep() function
|
// These defines are needed for the windows Sleep() function
|
||||||
// - comment them out if you don't want the Sleep function.
|
// - comment them out if you don't want the Sleep function.
|
||||||
//#ifdef _WIN32
|
//#ifdef _WIN32
|
||||||
|
|
@ -158,36 +158,24 @@ void ct2ctml(const char* file, const int debug)
|
||||||
// This command works on windows machines if Windows.h and Winbase.h are included
|
// This command works on windows machines if Windows.h and Winbase.h are included
|
||||||
// Sleep(5000);
|
// Sleep(5000);
|
||||||
#endif
|
#endif
|
||||||
// show the contents of the log file on the screen
|
|
||||||
try {
|
|
||||||
char ch=0;
|
|
||||||
string s = "";
|
|
||||||
ifstream ferr("ct2ctml.log");
|
|
||||||
if (ferr) {
|
|
||||||
while (!ferr.eof()) {
|
|
||||||
ferr.get(ch);
|
|
||||||
s += ch;
|
|
||||||
if (ch == '\n') {
|
|
||||||
writelog(s);
|
|
||||||
s = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ferr.close();
|
|
||||||
} else {
|
|
||||||
if (debug > 0) {
|
|
||||||
writelog("cannot open ct2ctml.log for reading.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (std::exception& err) {
|
|
||||||
writelog("ct2ctml: Exception while trying to parse ct2ctml.log:\n");
|
|
||||||
writelog(err.what());
|
|
||||||
}
|
|
||||||
if (ierr != 0) {
|
if (ierr != 0) {
|
||||||
string msg = cmd;
|
// Generate an error message that includes the contents of the
|
||||||
writelog("ct2ctml: throw cantera error \n");
|
// ct2ctml log file.
|
||||||
throw CanteraError("ct2ctml",
|
stringstream message;
|
||||||
"could not convert input file to CTML.\n "
|
message << "Error converting input file \"" << file << "\" to CTML.\n";
|
||||||
"Command line was: \n" + msg);
|
message << "Command was:\n\n";
|
||||||
|
message << cmd << "\n\n";
|
||||||
|
ifstream ferr(logfile.c_str());
|
||||||
|
if (ferr) {
|
||||||
|
message << "-------------- start of ct2ctml.log --------------\n";
|
||||||
|
message << ferr.rdbuf();
|
||||||
|
message << "--------------- end of ct2ctml.log ---------------";
|
||||||
|
} else {
|
||||||
|
message << "Additionally, the contents of ct2ctml.log"
|
||||||
|
"could not be read";
|
||||||
|
}
|
||||||
|
throw CanteraError("ct2ctml", message.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the conversion succeeded and DEBUG_PATHS is not defined,
|
// if the conversion succeeded and DEBUG_PATHS is not defined,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue