Attach flight data to simulation exceptions so it can be preserved to help user track down the problem
This commit is contained in:
parent
88bf25e41d
commit
fa81fef5ae
@ -384,15 +384,19 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
simulatedData = simulator.simulate(simulationConditions);
|
||||
t2 = System.currentTimeMillis();
|
||||
log.debug("Simulation: returning from simulator, simulation took " + (t2 - t1) + "ms");
|
||||
|
||||
// Set simulated info after simulation, will not be set in case of exception
|
||||
|
||||
} catch (SimulationException e) {
|
||||
simulatedData = e.getFlightData();
|
||||
throw e;
|
||||
} finally {
|
||||
// Set simulated info after simulation
|
||||
simulatedConditions = options.clone();
|
||||
simulatedConfigurationDescription = descriptor.format( this.rocket, getId());
|
||||
simulatedRocketID = rocket.getFunctionalModID();
|
||||
|
||||
status = Status.UPTODATE;
|
||||
fireChangeEvent();
|
||||
} finally {
|
||||
|
||||
mutex.unlock("simulate");
|
||||
}
|
||||
}
|
||||
|
@ -58,12 +58,14 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
||||
|
||||
// this is just a list of simulation branches to
|
||||
Deque<SimulationStatus> toSimulate = new ArrayDeque<SimulationStatus>();
|
||||
|
||||
FlightData flightData;
|
||||
|
||||
@Override
|
||||
public FlightData simulate(SimulationConditions simulationConditions) throws SimulationException {
|
||||
|
||||
// Set up flight data
|
||||
FlightData flightData = new FlightData();
|
||||
flightData = new FlightData();
|
||||
|
||||
// Set up rocket configuration
|
||||
this.fcid = simulationConditions.getFlightConfigurationID();
|
||||
@ -268,6 +270,11 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
||||
|
||||
// Add FlightEvent for Abort.
|
||||
currentStatus.getFlightData().addEvent(new FlightEvent(FlightEvent.Type.EXCEPTION, currentStatus.getSimulationTime(), currentStatus.getConfiguration().getRocket(), e.getLocalizedMessage()));
|
||||
|
||||
flightData.addBranch(currentStatus.getFlightData());
|
||||
flightData.getWarningSet().addAll(currentStatus.getWarnings());
|
||||
|
||||
e.setFlightData(flightData);
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
package net.sf.openrocket.simulation.exception;
|
||||
|
||||
import net.sf.openrocket.simulation.FlightData;
|
||||
|
||||
public class SimulationException extends Exception {
|
||||
|
||||
private FlightData flightData = null;
|
||||
|
||||
public SimulationException() {
|
||||
|
||||
}
|
||||
@ -18,4 +22,11 @@ public class SimulationException extends Exception {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public void setFlightData(FlightData f) {
|
||||
flightData = f;
|
||||
}
|
||||
|
||||
public FlightData getFlightData() {
|
||||
return flightData;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user