Skip to content

Commit

Permalink
ENH: raises an error when user 'export_function' contains errors from…
Browse files Browse the repository at this point in the history
… any kind (attribute, logical, etc)
  • Loading branch information
Lucas-Prates committed Nov 11, 2024
1 parent 62b3edb commit b602949
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rocketpy/simulation/monte_carlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,14 @@ def __export_flight_data(
}

if self.export_function is not None:
additional_exports = self.export_function(flight)
try:
additional_exports = self.export_function(flight)
except Exception as e:
raise ValueError(

Check warning on line 378 in rocketpy/simulation/monte_carlo.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/simulation/monte_carlo.py#L374-L378

Added lines #L374 - L378 were not covered by tests
"An error was encountered running your custom export function. "
"Check for errors in 'export_function' definition."
) from e

for key in additional_exports.keys():
if key in self.export_list:
raise ValueError(

Check warning on line 385 in rocketpy/simulation/monte_carlo.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/simulation/monte_carlo.py#L383-L385

Added lines #L383 - L385 were not covered by tests
Expand Down

0 comments on commit b602949

Please sign in to comment.