diff --git a/include/cantera/kinetics/RxnRates.h b/include/cantera/kinetics/RxnRates.h index c1872b748..3ff7590cf 100644 --- a/include/cantera/kinetics/RxnRates.h +++ b/include/cantera/kinetics/RxnRates.h @@ -9,9 +9,11 @@ #define CT_RXNRATES_H #include "reaction_defs.h" -#include "cantera/base/ctexceptions.h" #include "ReactionData.h" +#include "cantera/base/ctexceptions.h" +#include "cantera/base/stringUtils.h" + namespace Cantera { diff --git a/src/base/ctexceptions.cpp b/src/base/ctexceptions.cpp index f92eed963..116025385 100644 --- a/src/base/ctexceptions.cpp +++ b/src/base/ctexceptions.cpp @@ -40,7 +40,8 @@ void CanteraError::save() const char* CanteraError::what() const throw() { try { - formattedMessage_ = stars; + formattedMessage_ = "\n"; + formattedMessage_ += stars; formattedMessage_ += getClass() + " thrown by " + procedure_ + ":\n" + getMessage(); if (formattedMessage_.compare(formattedMessage_.size()-1, 1, "\n")) { formattedMessage_.append("\n"); diff --git a/src/kinetics/importKinetics.cpp b/src/kinetics/importKinetics.cpp index 563ed1d4c..67c557e5b 100644 --- a/src/kinetics/importKinetics.cpp +++ b/src/kinetics/importKinetics.cpp @@ -478,7 +478,6 @@ static void getFalloff(const XML_Node& f, ReactionData& rdata) */ static void getEfficiencies(const XML_Node& eff, Kinetics& kin, ReactionData& rdata) { - // set the default collision efficiency rdata.default_3b_eff = fpValue(eff["default"]); @@ -489,6 +488,11 @@ static void getEfficiencies(const XML_Node& eff, Kinetics& kin, ReactionData& rd for (size_t n = 0; n < key.size(); n++) { // ; bb != ee; ++bb) { nm = key[n];// bb->first; size_t k = kin.kineticsSpeciesIndex(nm, phse); + if (k == npos) { + throw CanteraError("getEfficiencies", "Encountered third-body " + "efficiency for undefined species \"" + nm + "\"\n" + "while adding reaction " + int2str(rdata.number+1) + "."); + } rdata.thirdBodyEfficiencies[k] = fpValue(val[n]); // bb->second; } } @@ -1183,39 +1187,31 @@ bool buildSolutionFromXML(XML_Node& root, std::string id, std::string nm, ThermoPhase* th, Kinetics* k) { XML_Node* x; - try { - - x = get_XML_NameID(nm, string("#")+id, &root); - // x = get_XML_Node(string("#")+id, &root); - if (!x) { - return false; - } - - /* - * Fill in the ThermoPhase object by querying the - * const XML_Node tree located at x. - */ - importPhase(*x, th); - /* - * Create a vector of ThermoPhase pointers of length 1 - * having the current th ThermoPhase as the entry. - */ - vector phases(1); - phases[0] = th; - /* - * Fill in the kinetics object k, by querying the - * const XML_Node tree located by x. The source terms and - * eventually the source term vector will be constructed - * from the list of ThermoPhases in the vector, phases. - */ - importKinetics(*x, phases, k); - - return true; - } catch (CanteraError& err) { - err.save(); - throw CanteraError("buildSolutionFromXML","error encountered"); + x = get_XML_NameID(nm, string("#")+id, &root); + // x = get_XML_Node(string("#")+id, &root); + if (!x) { return false; } + + /* + * Fill in the ThermoPhase object by querying the + * const XML_Node tree located at x. + */ + importPhase(*x, th); + /* + * Create a vector of ThermoPhase pointers of length 1 + * having the current th ThermoPhase as the entry. + */ + vector phases(1); + phases[0] = th; + /* + * Fill in the kinetics object k, by querying the + * const XML_Node tree located by x. The source terms and + * eventually the source term vector will be constructed + * from the list of ThermoPhases in the vector, phases. + */ + importKinetics(*x, phases, k); + return true; } }