code clean RuntimeExceptions

This commit is contained in:
Patrick Haßel 2025-02-26 10:38:43 +01:00
parent dfc374b13a
commit 27d827b9d6
3 changed files with 4 additions and 6 deletions

View File

@ -53,7 +53,7 @@ public enum Alignment {
} else if (this.amount instanceof final Period period) { } else if (this.amount instanceof final Period period) {
return period.multipliedBy((int) amount); return period.multipliedBy((int) amount);
} }
throw new RuntimeException(); throw new RuntimeException("Cannot multiply unimplemented TemporalAmount: %s".formatted(this.amount));
} }
} }

View File

@ -14,7 +14,7 @@ public class GraphPoint {
@NonNull @NonNull
public GraphPoint plus(@NonNull final GraphPoint other) { public GraphPoint plus(@NonNull final GraphPoint other) {
if (this.date.compareTo(other.date) != 0) { if (this.date.compareTo(other.date) != 0) {
throw new RuntimeException(); throw new RuntimeException("Cannot 'add' GraphPoints with different dates: this=%s, other=%s".formatted(this, other));
} }
return new GraphPoint(date, value + other.value); return new GraphPoint(date, value + other.value);
} }

View File

@ -31,10 +31,8 @@ public abstract class MeterValue {
public void update(@NonNull final Value value) { public void update(@NonNull final Value value) {
final double converted = value.as(id.getMeter().getSeries().getUnit()).value; final double converted = value.as(id.getMeter().getSeries().getUnit()).value;
if (converted < this.max) { this.min = Math.min(this.min, converted);
throw new RuntimeException(); this.max = Math.max(this.max, converted);
}
this.max = converted;
} }
@Data @Data