diff --git a/include/cantera/base/ctexceptions.h b/include/cantera/base/ctexceptions.h index 82c6d2067..3f21b51b1 100644 --- a/include/cantera/base/ctexceptions.h +++ b/include/cantera/base/ctexceptions.h @@ -225,7 +225,7 @@ public: # define AssertThrow(expr, procedure) ((void) (0)) #endif #ifndef AssertThrowMsg -# define AssertThrowMsg(expr,procedure, message) ((void) (0)) +# define AssertThrowMsg(expr,procedure, ...) ((void) (0)) #endif #else @@ -271,14 +271,14 @@ public: * @ingroup errorhandling */ #ifndef AssertThrowMsg -# define AssertThrowMsg(expr, procedure, message) ((expr) ? (void) 0 : throw CanteraError(procedure + std::string(": at failed assert: \"") + std::string(#expr) + std::string("\""), message)) +# define AssertThrowMsg(expr, procedure, ...) ((expr) ? (void) 0 : throw CanteraError(procedure + std::string(":\nfailed assert: \"") + std::string(#expr) + std::string("\""), __VA_ARGS__)) #endif #endif //! Throw an exception if the specified exception is not a finite number. #ifndef AssertFinite -# define AssertFinite(expr, procedure, message) AssertThrowMsg(expr < BigNumber && expr > -BigNumber, procedure, message) +# define AssertFinite(expr, procedure, ...) AssertThrowMsg(expr < BigNumber && expr > -BigNumber, procedure, __VA_ARGS__) #endif } diff --git a/include/cantera/kinetics/RxnRates.h b/include/cantera/kinetics/RxnRates.h index 43bab4f22..53c3cb910 100644 --- a/include/cantera/kinetics/RxnRates.h +++ b/include/cantera/kinetics/RxnRates.h @@ -192,9 +192,9 @@ public: auto iter = pressures_.upper_bound(c[0]); AssertThrowMsg(iter != pressures_.end(), "Plog::update_C", - "Pressure out of range: " + fp2str(logP_)); + "Pressure out of range: {}", logP_); AssertThrowMsg(iter != pressures_.begin(), "Plog::update_C", - "Pressure out of range: " + fp2str(logP_)); + "Pressure out of range: {}", logP_); // upper interpolation pressure logP2_ = iter->first; diff --git a/src/equil/vcs_VolPhase.cpp b/src/equil/vcs_VolPhase.cpp index 8ff374465..85c73a41e 100644 --- a/src/equil/vcs_VolPhase.cpp +++ b/src/equil/vcs_VolPhase.cpp @@ -821,8 +821,8 @@ void vcs_VolPhase::setTotalMoles(const double totalMols) m_existence = VCS_PHASE_EXIST_ALWAYS; AssertThrowMsg(totalMols >= m_totalMolesInert, "vcs_VolPhase::setTotalMoles", - "totalMoles less than inert moles: " + - fp2str(totalMols) + " " + fp2str(m_totalMolesInert)); + "totalMoles less than inert moles: {} {}", + totalMols, m_totalMolesInert); } else { if (m_singleSpecies && (m_phiVarIndex == 0)) { m_existence = VCS_PHASE_EXIST_ALWAYS; diff --git a/src/equil/vcs_elem_rearrange.cpp b/src/equil/vcs_elem_rearrange.cpp index d7760bdb9..68bb9bd77 100644 --- a/src/equil/vcs_elem_rearrange.cpp +++ b/src/equil/vcs_elem_rearrange.cpp @@ -170,7 +170,7 @@ void VCS_SOLVE::vcs_switch_elem_pos(size_t ipos, size_t jpos) } AssertThrowMsg(ipos < m_numElemConstraints && jpos < m_numElemConstraints, "vcs_switch_elem_pos", - "inappropriate args: " + int2str(ipos) + " " + int2str(jpos)); + "inappropriate args: {} {}", ipos, jpos); /* * Change the element Global Index list in each vcs_VolPhase object * to reflect the switch in the element positions. diff --git a/src/equil/vcs_phaseStability.cpp b/src/equil/vcs_phaseStability.cpp index af20604d2..b00bab5d4 100644 --- a/src/equil/vcs_phaseStability.cpp +++ b/src/equil/vcs_phaseStability.cpp @@ -29,8 +29,8 @@ bool VCS_SOLVE::vcs_popPhasePossible(const size_t iphasePop) const size_t kspec = Vphase->spGlobalIndexVCS(k); AssertThrowMsg(m_molNumSpecies_old[kspec] <= 0.0, "VCS_SOLVE::vcs_popPhasePossible", - "we shouldn't be here " + int2str(kspec) + " "+ - fp2str(m_molNumSpecies_old[kspec]) + " > 0.0"); + "we shouldn't be here {}: {} > 0.0", kspec, + m_molNumSpecies_old[kspec]); size_t irxn = kspec - m_numComponents; if (kspec >= m_numComponents) { bool iPopPossible = true; diff --git a/src/equil/vcs_solve_TP.cpp b/src/equil/vcs_solve_TP.cpp index 30f501dc2..2740475bb 100644 --- a/src/equil/vcs_solve_TP.cpp +++ b/src/equil/vcs_solve_TP.cpp @@ -947,9 +947,8 @@ void VCS_SOLVE::solve_tp_inner(size_t& iti, size_t& it1, AssertThrowMsg(fabs(m_deltaMolNumSpecies[kspec] -dx) < 1.0E-14*(fabs(m_deltaMolNumSpecies[kspec]) + fabs(dx) + 1.0E-32), "VCS_SOLVE::solve_tp_inner", - "ds[kspec] = " + fp2str(m_deltaMolNumSpecies[kspec]) + - " dx = " + fp2str(dx) + " , kspec = " + int2str(kspec) + - "\nwe have a problem!"); + "ds[kspec] = {}, dx = {}, kspec = {}\nwe have a problem!", + m_deltaMolNumSpecies[kspec], dx, kspec); for (size_t k = 0; k < m_numComponents; ++k) { m_deltaMolNumSpecies[k] += sc_irxn[k] * dx; } @@ -1748,7 +1747,7 @@ int VCS_SOLVE::delta_species(const size_t kspec, double* const delta_ptr) int retn = 1; double delta = *delta_ptr; AssertThrowMsg(kspec >= m_numComponents, "VCS_SOLVE::delta_species", - "delete_species() ERROR: called for a component " + int2str(kspec)); + "delete_species() ERROR: called for a component {}", kspec); if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { /* * Attempt the given dx. If it doesn't work, try to see if a smaller @@ -3315,8 +3314,8 @@ void VCS_SOLVE::vcs_dfe(const int stateCalc, for (size_t iph = 0; iph < m_numPhases; iph++) { AssertThrowMsg(vcs_doubleEqual(tlogMoles[iph], tPhMoles_ptr[iph]), "VCS_SOLVE::vcs_dfe", - "phase Moles may be off, iph = " + int2str(iph) + ", " + - fp2str(tlogMoles[iph]) + " " + fp2str(tPhMoles_ptr[iph])); + "phase Moles may be off, iph = {}, {} {}", + iph, tlogMoles[iph], tPhMoles_ptr[iph]); } m_TmpPhase.assign(m_TmpPhase.size(), 0.0); for (size_t iph = 0; iph < m_numPhases; iph++) { diff --git a/src/fortran/fctxml.cpp b/src/fortran/fctxml.cpp index 8448d937e..3bb9c3142 100644 --- a/src/fortran/fctxml.cpp +++ b/src/fortran/fctxml.cpp @@ -296,7 +296,7 @@ extern "C" { // array not big enough if (*n < nv) { throw CanteraError("ctml_getfloatarray", - "array must be dimensioned at least "+Cantera::int2str(nv)); + "array must be dimensioned at least {}", nv); } for (int i = 0; i < nv; i++) { diff --git a/src/kinetics/GasKinetics.cpp b/src/kinetics/GasKinetics.cpp index 8ac2a0a70..46dbc62f8 100644 --- a/src/kinetics/GasKinetics.cpp +++ b/src/kinetics/GasKinetics.cpp @@ -144,7 +144,7 @@ void GasKinetics::processFalloffReactions() for (size_t i = 0; i < m_nfall; i++) { pr[i] = concm_falloff_values[i] * m_rfn_low[i] / (m_rfn_high[i] + SmallNumber); AssertFinite(pr[i], "GasKinetics::processFalloffReactions", - "pr[" + int2str(i) + "] is not finite."); + "pr[{}] is not finite.", i); } m_falloffn.pr_to_falloff(pr.data(), falloff_work.data()); @@ -203,11 +203,11 @@ void GasKinetics::updateROP() for (size_t i = 0; i < m_rfn.size(); i++) { AssertFinite(m_rfn[i], "GasKinetics::updateROP", - "m_rfn[" + int2str(i) + "] is not finite."); + "m_rfn[{}] is not finite.", i); AssertFinite(m_ropf[i], "GasKinetics::updateROP", - "m_ropf[" + int2str(i) + "] is not finite."); + "m_ropf[{}] is not finite.", i); AssertFinite(m_ropr[i], "GasKinetics::updateROP", - "m_ropr[" + int2str(i) + "] is not finite."); + "m_ropr[{}] is not finite.", i); } m_ROP_ok = true; } diff --git a/src/kinetics/Kinetics.cpp b/src/kinetics/Kinetics.cpp index 8735ec83e..2aacf2291 100644 --- a/src/kinetics/Kinetics.cpp +++ b/src/kinetics/Kinetics.cpp @@ -224,7 +224,7 @@ std::pair Kinetics::checkDuplicates(bool throw_err) const throw CanteraError("installReaction", "Undeclared duplicate reactions detected:\n" "Reaction {}: {}\nReaction {}: {}\n", - int2str(i+1), other.equation(), int2str(m+1), R.equation()); + i+1, other.equation(), m+1, R.equation()); } else { return make_pair(i,m); } diff --git a/src/oneD/Sim1D.cpp b/src/oneD/Sim1D.cpp index 1fc036174..3358be3eb 100644 --- a/src/oneD/Sim1D.cpp +++ b/src/oneD/Sim1D.cpp @@ -51,8 +51,7 @@ void Sim1D::setValue(size_t dom, size_t comp, size_t localPoint, doublereal valu { size_t iloc = domain(dom).loc() + domain(dom).index(comp, localPoint); AssertThrowMsg(iloc < m_x.size(), "Sim1D::setValue", - "Index out of bounds:" + int2str(iloc) + " > " + - int2str(m_x.size())); + "Index out of bounds: {} > {}", iloc, m_x.size()); m_x[iloc] = value; } @@ -60,8 +59,7 @@ doublereal Sim1D::value(size_t dom, size_t comp, size_t localPoint) const { size_t iloc = domain(dom).loc() + domain(dom).index(comp, localPoint); AssertThrowMsg(iloc < m_x.size(), "Sim1D::value", - "Index out of bounds:" + int2str(iloc) + " > " + - int2str(m_x.size())); + "Index out of bounds: {} > {}", iloc, m_x.size()); return m_x[iloc]; } @@ -69,8 +67,7 @@ doublereal Sim1D::workValue(size_t dom, size_t comp, size_t localPoint) const { size_t iloc = domain(dom).loc() + domain(dom).index(comp, localPoint); AssertThrowMsg(iloc < m_x.size(), "Sim1D::workValue", - "Index out of bounds:" + int2str(iloc) + " > " + - int2str(m_x.size())); + "Index out of bounds: {} > {}", iloc, m_x.size()); return m_xnew[iloc]; } diff --git a/src/thermo/GeneralSpeciesThermo.cpp b/src/thermo/GeneralSpeciesThermo.cpp index cb7fe6502..fc9b6dfc8 100644 --- a/src/thermo/GeneralSpeciesThermo.cpp +++ b/src/thermo/GeneralSpeciesThermo.cpp @@ -80,8 +80,9 @@ void GeneralSpeciesThermo::install_STIT(size_t index, throw CanteraError("GeneralSpeciesThermo::install_STIT", "zero pointer"); } - AssertThrow(m_speciesLoc.find(index) == m_speciesLoc.end(), - "Index position isn't null, duplication of assignment: " + int2str(index)); + AssertThrowMsg(m_speciesLoc.find(index) == m_speciesLoc.end(), + "GeneralSpeciesThermo::install_STIT", + "Index position isn't null, duplication of assignment: {}", index); int type = stit_ptr->reportType(); m_speciesLoc[index] = std::make_pair(type, m_sp[type].size()); m_sp[type].push_back(std::make_pair(index, stit_ptr));