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