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!
This commit is contained in:
		
							parent
							
								
									1c7171eff2
								
							
						
					
					
						commit
						16091b456d
					
				| @ -145,14 +145,15 @@ public class ThrustCurveMotor implements Motor, Comparable<ThrustCurveMotor>, Se | |||||||
| 			if (motor.time.length < 2) { | 			if (motor.time.length < 2) { | ||||||
| 				throw new IllegalArgumentException("Too short thrust-curve, length=" + motor.time.length); | 				throw new IllegalArgumentException("Too short thrust-curve, length=" + motor.time.length); | ||||||
| 			} | 			} | ||||||
|  | 			 | ||||||
| 			for (int i = 0; i < motor.time.length - 1; i++) { | 			for (int i = 0; i < motor.time.length - 1; i++) { | ||||||
| 				if (motor.time[i + 1] <= motor.time[i]) { | 				if (motor.time[i + 1] <= motor.time[i]) { | ||||||
| 					throw new IllegalArgumentException("Time stalls or goes backwards, " + | 					throw new IllegalArgumentException("Two thrust values for single time point, " + | ||||||
| 							"time[" + i + "]=" + motor.time[i] + " " + | 													   "time[" + i + "]=" + motor.time[i] + ", thrust=" + motor.thrust[i] + | ||||||
| 							"time[" + (i + 1) + "]=" + motor.time[i + 1] + | 													   "; time[" + (i + 1) + "]=" + motor.time[i + 1] + ", thrust=" + motor.thrust[i+1]); | ||||||
| 													   ", thrust=(" + motor.thrust[i] + ", " + motor.thrust[i+1] + ")"); |  | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  | 
 | ||||||
| 			if (!MathUtil.equals(motor.time[0], 0)) { | 			if (!MathUtil.equals(motor.time[0], 0)) { | ||||||
| 				throw new IllegalArgumentException("Curve starts at time " + motor.time[0]); | 				throw new IllegalArgumentException("Curve starts at time " + motor.time[0]); | ||||||
| 			} | 			} | ||||||
|  | |||||||
| @ -145,7 +145,7 @@ public class SerializeThrustcurveMotors { | |||||||
| 
 | 
 | ||||||
| 						allMotors.add(builder.build()); | 						allMotors.add(builder.build()); | ||||||
| 					} catch (IllegalArgumentException e) { | 					} 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 { | 						try { | ||||||
| 							FileOutputStream out = new FileOutputStream(("simfile-" + burnFile.getSimfileId()).toString()); | 							FileOutputStream out = new FileOutputStream(("simfile-" + burnFile.getSimfileId()).toString()); | ||||||
| 							out.write(burnFile.getContents().getBytes()); | 							out.write(burnFile.getContents().getBytes()); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user