Fix calls to CanteraError with blank or incorrect first argument

The first argument should be the function name from which the exception was
thrown. Leaving this blank makes it difficult to track down the location of the
exception.
This commit is contained in:
Ray Speth 2015-06-09 11:58:51 -04:00
parent 8dcde36d20
commit 217d780233
16 changed files with 43 additions and 35 deletions

View file

@ -23,7 +23,7 @@ public:
XML_Node* x = get_XML_Node("#"+id, m_r);
if (!x) {
throw CanteraError("Edge","error in get_XML_Node");
throw CanteraError("Edge::Edge","error in get_XML_Node");
}
importPhase(*x, this);

View file

@ -18,7 +18,7 @@ public:
id = "";
}
m_ok = buildSolutionFromXML(*m_r, id, "phase", this, 0);
if (!m_ok) throw CanteraError("Metal",
if (!m_ok) throw CanteraError("Metal::Metal",
"buildSolutionFromXML returned false");
}

View file

@ -162,7 +162,7 @@ public:
if (n < data.size()) {
return *data[n];
} else {
throw Cantera::CanteraError("item","index out of range"+Cantera::int2str(n));
throw Cantera::CanteraError("Cabinet::item","index out of range"+Cantera::int2str(n));
}
}

View file

@ -324,7 +324,7 @@ size_t Cantera::BasisOptimize(int* usedZeroedSpecies, bool doFormRxn,
vector_int ipiv(nComponents);
ct_dgetrf(nComponents, nComponents, &sm[0], ne, &ipiv[0], info);
if (info) {
throw CanteraError("basopt", "factorization returned an error condition");
throw CanteraError("BasisOptimize", "factorization returned an error condition");
}
ct_dgetrs(ctlapack::NoTranspose, nComponents, nNonComponents, &sm[0], ne,
&ipiv[0], &formRxnMatrix[0], ne, info);

View file

@ -174,7 +174,7 @@ void ChemEquil::update(const thermo_t& s)
for (size_t k = 0; k < m_kk; k++) {
m_elementmolefracs[m] += nAtoms(k,m) * m_molefractions[k];
if (m_molefractions[k] < 0.0) {
throw CanteraError("update",
throw CanteraError("ChemEquil::update",
"negative mole fraction for "+s.speciesName(k)+
": "+fp2str(m_molefractions[k]));
}

View file

@ -441,7 +441,7 @@ void MultiPhaseEquil::step(doublereal omega, vector_fp& deltaN,
{
size_t k, ik;
if (omega < 0.0) {
throw CanteraError("step","negative omega");
throw CanteraError("MultiPhaseEquil::step","negative omega");
}
for (ik = 0; ik < m_nel; ik++) {

View file

@ -552,7 +552,7 @@ double ElectrodeKinetics::calcForwardROP_BV(size_t irxn, size_t iBeta, double io
int iECDFormulation = m_ctrxn_ecdf[iBeta];
if (!iECDFormulation) {
throw CanteraError("", "not handled yet");
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV", "not handled yet");
}
//
// Calculate the forward chemical and modify the forward reaction rate coefficient
@ -611,7 +611,7 @@ double ElectrodeKinetics::calcForwardROP_BV(size_t irxn, size_t iBeta, double io
} else {
#ifdef DEBUG_MODE
if (ioc > 0) {
throw CanteraError(" ", "ioc should be less than zero here");
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV", "ioc should be less than zero here");
}
#endif
double exp2 = -nu * nStoich * Faraday * (1.0 - beta) / (rt);
@ -645,7 +645,7 @@ double ElectrodeKinetics::calcForwardROP_BV_NoAct(size_t irxn, size_t iBeta, dou
int iECDFormulation = m_ctrxn_ecdf[iBeta];
if (!iECDFormulation) {
throw CanteraError("", "not handled yet");
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV_NoAct", "not handled yet");
}
//
// Calculate the forward chemical and modify the forward reaction rate coefficient
@ -712,7 +712,7 @@ double ElectrodeKinetics::calcForwardROP_BV_NoAct(size_t irxn, size_t iBeta, dou
} else {
#ifdef DEBUG_MODE
if (ioc > 0) {
throw CanteraError(" ", "ioc should be less than zero here");
throw CanteraError("ElectrodeKinetics::calcForwardROP_BV_NoAct", "ioc should be less than zero here");
}
#endif
double exp2 = -nu * nStoich * Faraday * (1.0 - beta) / (rt);

View file

@ -404,7 +404,7 @@ void OneDim::save(const std::string& fname, std::string id,
}
ofstream s(fname.c_str());
if (!s) {
throw CanteraError("save","could not open file "+fname);
throw CanteraError("OneDim::save","could not open file "+fname);
}
root.write(s);
s.close();

View file

@ -28,7 +28,7 @@ Bdry1D::Bdry1D() : Domain1D(1, 1, 0.0),
void Bdry1D::_init(size_t n)
{
if (m_index == npos) {
throw CanteraError("Bdry1D",
throw CanteraError("Bdry1D::_init",
"install in container before calling init.");
}
@ -49,7 +49,7 @@ void Bdry1D::_init(size_t n)
m_left_nsp = m_left_nv - 4;
m_phase_left = &m_flow_left->phase();
} else
throw CanteraError("Bdry1D::init",
throw CanteraError("Bdry1D::_init",
"Boundary domains can only be "
"connected on the left to flow domains, not type "+int2str(r.domainType())
+ " domains.");
@ -66,7 +66,7 @@ void Bdry1D::_init(size_t n)
m_right_nsp = m_right_nv - 4;
m_phase_right = &m_flow_right->phase();
} else
throw CanteraError("Bdry1D::init",
throw CanteraError("Bdry1D::_init",
"Boundary domains can only be "
"connected on the right to flow domains, not type "+int2str(r.domainType())
+ " domains.");

View file

@ -590,11 +590,13 @@ void IonsFromNeutralVPSSTP::calcNeutralMoleculeMoleFractions() const
if (fabs(moleFractionsTmp_[k]) > 1.0E-13) {
//! Check to see if we have in fact found the inverse.
if (anionList_[0] != k) {
throw CanteraError("", "neutral molecule calc error");
throw CanteraError("IonsFromNeutralVPSSTP::calcNeutralMoleculeMoleFractions",
"neutral molecule calc error");
} else {
//! For the single anion case, we will allow some slippage
if (fabs(moleFractionsTmp_[k]) > 1.0E-5) {
throw CanteraError("", "neutral molecule calc error - anion");
throw CanteraError("IonsFromNeutralVPSSTP::calcNeutralMoleculeMoleFractions",
"neutral molecule calc error - anion");
}
}
}
@ -614,18 +616,18 @@ void IonsFromNeutralVPSSTP::calcNeutralMoleculeMoleFractions() const
case cIonSolnType_SINGLECATION:
throw CanteraError("eosType", "Unknown type");
throw CanteraError("IonsFromNeutralVPSSTP::calcNeutralMoleculeMoleFractions", "Unknown type");
break;
case cIonSolnType_MULTICATIONANION:
throw CanteraError("eosType", "Unknown type");
throw CanteraError("IonsFromNeutralVPSSTP::calcNeutralMoleculeMoleFractions", "Unknown type");
break;
default:
throw CanteraError("eosType", "Unknown type");
throw CanteraError("IonsFromNeutralVPSSTP::calcNeutralMoleculeMoleFractions", "Unknown type");
break;
}
@ -688,11 +690,13 @@ void IonsFromNeutralVPSSTP::getNeutralMoleculeMoleGrads(const doublereal* const
if (fabs(moleFractionsTmp_[k]) > 1.0E-13) {
//! Check to see if we have in fact found the inverse.
if (anionList_[0] != k) {
throw CanteraError("", "neutral molecule calc error");
throw CanteraError("IonsFromNeutralVPSSTP::getNeutralMoleculeMoleGrads",
"neutral molecule calc error");
} else {
//! For the single anion case, we will allow some slippage
if (fabs(moleFractionsTmp_[k]) > 1.0E-5) {
throw CanteraError("", "neutral molecule calc error - anion");
throw CanteraError("IonsFromNeutralVPSSTP::getNeutralMoleculeMoleGrads",
"neutral molecule calc error - anion");
}
}
}
@ -714,18 +718,21 @@ void IonsFromNeutralVPSSTP::getNeutralMoleculeMoleGrads(const doublereal* const
case cIonSolnType_SINGLECATION:
throw CanteraError("eosType", "Unknown type");
throw CanteraError("IonsFromNeutralVPSSTP::getNeutralMoleculeMoleGrads",
"Unknown type");
break;
case cIonSolnType_MULTICATIONANION:
throw CanteraError("eosType", "Unknown type");
throw CanteraError("IonsFromNeutralVPSSTP::getNeutralMoleculeMoleGrads",
"Unknown type");
break;
default:
throw CanteraError("eosType", "Unknown type");
throw CanteraError("IonsFromNeutralVPSSTP::getNeutralMoleculeMoleGrads",
"Unknown type");
break;
}

View file

@ -448,7 +448,7 @@ void LatticeSolidPhase::setParametersFromXML(const XML_Node& eosdata)
}
}
if (!found) {
throw CanteraError("", "not found");
throw CanteraError("LatticeSolidPhase::setParametersFromXML", "not found");
}
}

View file

@ -745,12 +745,12 @@ int MixtureFugacityTP::phaseState(bool checkState) const
doublereal MixtureFugacityTP::densSpinodalLiquid() const
{
throw CanteraError("", "unimplemented");
throw CanteraError("MixtureFugacityTP::densSpinodalLiquid", "unimplemented");
}
doublereal MixtureFugacityTP::densSpinodalGas() const
{
throw CanteraError("", "unimplemented");
throw CanteraError("MixtureFugacityTP::densSpinodalGas", "unimplemented");
}
doublereal MixtureFugacityTP::satPressure(doublereal TKelvin)

View file

@ -139,7 +139,7 @@ PhaseCombo_Interaction::PhaseCombo_Interaction(int testProb) :
"Unable to find Li2Fe1S2(S)");
}
m_pSpecies_B_ij[0] = iLi2;
throw CanteraError("", "unimplemented");
throw CanteraError("PhaseCombo_Interaction test1 constructor", "unimplemented");
}
/*
@ -665,7 +665,7 @@ void PhaseCombo_Interaction::s_update_dlnActCoeff_dlnX_diag() const
dlnActCoeffdlnX_diag_[iA] += XA*XB*(2*g1*-2*g0-6*g1*XB);
dlnActCoeffdlnX_diag_[iB] += XA*XB*(2*g1*-2*g0-6*g1*XB);
}
throw CanteraError("", "unimplemented");
throw CanteraError("PhaseCombo_Interaction::s_update_dlnActCoeff_dlnX_diag", "unimplemented");
}
void PhaseCombo_Interaction::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const

View file

@ -103,7 +103,8 @@ RedlichKwongMFTP::RedlichKwongMFTP(int testProb) :
infile = "co2_redlichkwong.xml";
id_ = "carbondioxide";
} else {
throw CanteraError("", "test prob = 1 only");
throw CanteraError("RedlichKwongMFTP::RedlichKwongMFTP(int testProb)",
"test prob = 1 only");
}
XML_Node* root = get_XML_File(infile);
if (id_ == "-") {
@ -213,7 +214,7 @@ doublereal RedlichKwongMFTP::cp_mole() const
doublereal RedlichKwongMFTP::cv_mole() const
{
throw CanteraError("", "unimplemented");
throw CanteraError("RedlichKwongMFTP::cv_mole", "unimplemented");
return cp_mole() - GasConstant;
}
@ -850,7 +851,7 @@ void RedlichKwongMFTP::readXMLPureFluid(XML_Node& pureFluidParam)
m_formTempParam = 1;
}
} else {
throw CanteraError("", "unknown model");
throw CanteraError("RedlichKwongMFTP::readXMLPureFluid", "unknown model");
}
getFloatArray(xmlChild, vParams, true, "Pascal-m6/kmol2", "a_coeff");
@ -941,7 +942,7 @@ void RedlichKwongMFTP::readXMLCrossFluid(XML_Node& CrossFluidParam)
m_formTempParam = 1;
}
} else {
throw CanteraError("", "unknown model");
throw CanteraError("RedlichKwongMFTP::readXMLCrossFluid", "unknown model");
}
getFloatArray(xmlChild, vParams, true, "Pascal-m6/kmol2", "a_coeff");

View file

@ -127,7 +127,7 @@ LTPspecies* TransportFactory::newLTP(const XML_Node& trNode, const std::string&
ltps = new LTPspecies_ExpT(trNode, name, tp_ind, thermo);
break;
default:
throw CanteraError("newLTP","unknown transport model: " + model);
throw CanteraError("TransportFactory::newLTP","unknown transport model: " + model);
ltps = new LTPspecies(&trNode, name, tp_ind, thermo);
}
return ltps;

View file

@ -30,7 +30,7 @@ int main(int argc, char** argv)
size_t nsp = solid->nSpecies();
if (nsp != 1) {
throw CanteraError("","Should just be one species");
throw CanteraError("main","Should just be one species");
}
string sName;