Get rid of a bit of duplicate code

Handle case with no data in specified format for motor
This commit is contained in:
JoePfeiffer 2020-11-05 10:41:15 -07:00
parent 67fed96137
commit d231cb320f
2 changed files with 10 additions and 10 deletions

View File

@ -161,20 +161,20 @@ public class SerializeThrustcurveMotors {
} }
} }
} }
private static List<MotorBurnFile> getThrustCurvesForMotorId(int motorId) { private static List<MotorBurnFile> getThrustCurvesForMotorId(int motorId) {
String formats[] = new String[] {"RASP", "RockSim"};
List<MotorBurnFile> b = new ArrayList<>(); List<MotorBurnFile> b = new ArrayList<>();
try { for (String format : formats) {
b.addAll(ThrustCurveAPI.downloadData(motorId, "RockSim")); try {
} catch (Exception ex) { List<MotorBurnFile> motorData = ThrustCurveAPI.downloadData(motorId, format);
System.out.println("\tError downloading RockSim for motorID=" + motorId); if (motorData != null) {
} b.addAll(motorData);
try { }
b.addAll(ThrustCurveAPI.downloadData(motorId, "RASP")); } catch (Exception ex) {
} catch (Exception ex) { System.out.println("\tError downloading " + format + " for motorID=" + motorId + ": " + ex.getLocalizedMessage());
System.out.println("\tError downloading RASP for motorID=" + motorId); }
} }
return b; return b;
} }