[Python] Handle potential exceptions propagating from callbacks

Resolves side-issue noted in #1680
This commit is contained in:
Ray Speth 2024-06-06 00:01:42 -04:00 committed by Ingmar Schoegl
parent 1a6f711795
commit 4d6a3659be
2 changed files with 10 additions and 3 deletions

View File

@ -43,11 +43,11 @@ cdef extern from "cantera/base/Solution.h" namespace "Cantera":
void setSource(string)
CxxAnyMap& header() except +translate_exception
shared_ptr[CxxThermoPhase] thermo()
void setThermo(shared_ptr[CxxThermoPhase])
void setThermo(shared_ptr[CxxThermoPhase]) except +translate_exception
shared_ptr[CxxKinetics] kinetics()
void setKinetics(shared_ptr[CxxKinetics])
void setKinetics(shared_ptr[CxxKinetics]) except +translate_exception
shared_ptr[CxxTransport] transport()
void setTransport(shared_ptr[CxxTransport])
void setTransport(shared_ptr[CxxTransport]) except +translate_exception
void setTransportModel(const string&) except +translate_exception
CxxAnyMap parameters(cbool) except +translate_exception
size_t nAdjacent()

View File

@ -142,6 +142,13 @@ class TestOnedim(utilities.CanteraTest):
gas.transport_model = 'multicomponent'
assert flame.transport_model == 'multicomponent'
with pytest.raises(ct.CanteraError, match="Invalid Transport model"):
flame.transport_model = 'none'
gas.transport_model = 'unity-Lewis-number'
with pytest.raises(ct.CanteraError, match="Invalid Transport model"):
gas.transport_model = 'none'
class TestFreeFlame(utilities.CanteraTest):
tol_ss = [1.0e-5, 1.0e-14] # [rtol atol] for steady-state problem