Cantera 2.6.0
FuncEval.cpp
2#include <sstream>
3
4namespace Cantera
5{
6
7FuncEval::FuncEval()
8 : m_suppress_errors(false)
9{
10}
11
12int FuncEval::eval_nothrow(double t, double* y, double* ydot)
13{
14 try {
15 eval(t, y, ydot, m_sens_params.data());
16 } catch (CanteraError& err) {
17 if (suppressErrors()) {
18 m_errors.push_back(err.what());
19 } else {
20 writelog(err.what());
21 }
22 return 1; // possibly recoverable error
23 } catch (std::exception& err) {
24 if (suppressErrors()) {
25 m_errors.push_back(err.what());
26 } else {
27 writelog("FuncEval::eval_nothrow: unhandled exception:\n");
28 writelog(err.what());
30 }
31 return -1; // unrecoverable error
32 } catch (...) {
33 std::string msg = "FuncEval::eval_nothrow: unhandled exception"
34 " of unknown type\n";
35 if (suppressErrors()) {
36 m_errors.push_back(msg);
37 } else {
38 writelog(msg);
39 }
40 return -1; // unrecoverable error
41 }
42 return 0; // successful evaluation
43}
44
45std::string FuncEval::getErrors() const {
46 std::stringstream errs;
47 for (const auto& err : m_errors) {
48 errs << err;
49 errs << "\n";
50 }
51 return errs.str();
52}
53
54}
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
const char * what() const
Get a description of the error.
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
Definition: global.h:164
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
void writelogendl()
Write an end of line character to the screen and flush output.
Definition: global.cpp:42