From 16091b456d2a274bc27f069f3fc8cf51b3fa0201 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Fri, 1 May 2020 09:55:33 -0600 Subject: [PATCH] Clarifying error message when there are two data points for a single time. I wrote the original, and I still didn't understand it when I came across it for the first time in a few months! --- core/src/net/sf/openrocket/motor/ThrustCurveMotor.java | 9 +++++---- .../thrustcurve/SerializeThrustcurveMotors.java | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java index 68073b0ee..d2f8a7f51 100644 --- a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java +++ b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java @@ -145,14 +145,15 @@ public class ThrustCurveMotor implements Motor, Comparable, Se if (motor.time.length < 2) { throw new IllegalArgumentException("Too short thrust-curve, length=" + motor.time.length); } + for (int i = 0; i < motor.time.length - 1; i++) { if (motor.time[i + 1] <= motor.time[i]) { - throw new IllegalArgumentException("Time stalls or goes backwards, " + - "time[" + i + "]=" + motor.time[i] + " " + - "time[" + (i + 1) + "]=" + motor.time[i + 1] + - ", thrust=(" + motor.thrust[i] + ", " + motor.thrust[i+1] + ")"); + throw new IllegalArgumentException("Two thrust values for single time point, " + + "time[" + i + "]=" + motor.time[i] + ", thrust=" + motor.thrust[i] + + "; time[" + (i + 1) + "]=" + motor.time[i + 1] + ", thrust=" + motor.thrust[i+1]); } } + if (!MathUtil.equals(motor.time[0], 0)) { throw new IllegalArgumentException("Curve starts at time " + motor.time[0]); } diff --git a/core/src/net/sf/openrocket/thrustcurve/SerializeThrustcurveMotors.java b/core/src/net/sf/openrocket/thrustcurve/SerializeThrustcurveMotors.java index 173e26375..7adef3a03 100644 --- a/core/src/net/sf/openrocket/thrustcurve/SerializeThrustcurveMotors.java +++ b/core/src/net/sf/openrocket/thrustcurve/SerializeThrustcurveMotors.java @@ -145,7 +145,7 @@ public class SerializeThrustcurveMotors { allMotors.add(builder.build()); } catch (IllegalArgumentException e) { - System.out.println("\tError in simFile " + burnFile.getSimfileId() + ": " + e.getMessage() + " (continuing)"); + System.out.println("\tError in simFile " + burnFile.getSimfileId() + ": " + e.getMessage()); try { FileOutputStream out = new FileOutputStream(("simfile-" + burnFile.getSimfileId()).toString()); out.write(burnFile.getContents().getBytes());