@@ -171,30 +171,40 @@ cosim_algorithm* cosim_ecco_algorithm_create(
171171 double pGain,
172172 double iGain)
173173{
174- cosim::ecco_algorithm_params ecco_params = {
175- safetyFactor,
176- cosim::to_duration (stepSize),
177- cosim::to_duration (minStepSize),
178- cosim::to_duration (maxStepSize),
179- minChangeRate,
180- maxChangeRate,
181- absTolerance,
182- relTolerance,
183- pGain,
184- iGain};
185-
186- auto algo = std::make_unique<cosim_algorithm>();
187- algo->algorithm = std::make_shared<cosim::ecco_algorithm>(ecco_params);
188- algo->type = ECCO;
189- return algo.release ();
174+ try {
175+ cosim::ecco_algorithm_params ecco_params = {
176+ safetyFactor,
177+ cosim::to_duration (stepSize),
178+ cosim::to_duration (minStepSize),
179+ cosim::to_duration (maxStepSize),
180+ minChangeRate,
181+ maxChangeRate,
182+ absTolerance,
183+ relTolerance,
184+ pGain,
185+ iGain};
186+
187+ auto algo = std::make_unique<cosim_algorithm>();
188+ algo->algorithm = std::make_shared<cosim::ecco_algorithm>(ecco_params);
189+ algo->type = ECCO;
190+ return algo.release ();
191+ } catch (...) {
192+ handle_current_exception ();
193+ return nullptr ;
194+ }
190195}
191196
192197cosim_algorithm* cosim_fixed_step_algorithm_create (cosim_duration stepSize)
193198{
194- auto algo = std::make_unique<cosim_algorithm>();
195- algo->algorithm = std::make_shared<cosim::fixed_step_algorithm>(to_duration (stepSize));
196- algo->type = FIXED_STEP;
197- return algo.release ();
199+ try {
200+ auto algo = std::make_unique<cosim_algorithm>();
201+ algo->algorithm = std::make_shared<cosim::fixed_step_algorithm>(to_duration (stepSize));
202+ algo->type = FIXED_STEP;
203+ return algo.release ();
204+ } catch (...) {
205+ handle_current_exception ();
206+ return nullptr ;
207+ }
198208}
199209
200210struct cosim_execution_s
0 commit comments