Skip to content

Commit 76aa693

Browse files
committed
refine error messages
1 parent b78a144 commit 76aa693

File tree

1 file changed

+7
-7
lines changed
  • jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/vehicle

1 file changed

+7
-7
lines changed

jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/vehicle/VehicleImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private Builder(String id) {
145145
* @throws IllegalArgumentException if type is null
146146
*/
147147
public Builder setType(VehicleType type) {
148-
if (type == null) throw new IllegalArgumentException("type cannot be null.");
148+
if (type == null) throw new IllegalArgumentException("Vehicle type must not be null.");
149149
this.type = type;
150150
return this;
151151
}
@@ -213,7 +213,7 @@ public Builder setEndLocation(Location endLocation) {
213213
*/
214214
public Builder setEarliestStart(double earliest_startTime) {
215215
if (earliest_startTime < 0)
216-
throw new IllegalArgumentException("earliest start of vehicle " + id + " must not be negative");
216+
throw new IllegalArgumentException("The earliest start time of vehicle " + id + " must not be negative.");
217217
this.earliestStart = earliest_startTime;
218218
return this;
219219
}
@@ -226,7 +226,7 @@ public Builder setEarliestStart(double earliest_startTime) {
226226
*/
227227
public Builder setLatestArrival(double latest_arrTime) {
228228
if (latest_arrTime < 0)
229-
throw new IllegalArgumentException("latest arrival time of vehicle " + id + " must not be negative");
229+
throw new IllegalArgumentException("The latest arrival time of vehicle " + id + " must not be negative.");
230230
this.latestArrival = latest_arrTime;
231231
return this;
232232
}
@@ -254,17 +254,17 @@ public Builder addSkill(String skill) {
254254
*/
255255
public VehicleImpl build() {
256256
if (latestArrival < earliestStart)
257-
throw new IllegalArgumentException("latest arrival of vehicle " + id + " must not be smaller than its start time");
257+
throw new IllegalArgumentException("The latest arrival time of vehicle " + id + " must not be smaller than its start time.");
258258
if (startLocation != null && endLocation != null) {
259259
if (!startLocation.getId().equals(endLocation.getId()) && !returnToDepot)
260-
throw new IllegalArgumentException("this must not be. you specified both endLocationId and open-routes. this is contradictory. <br>" +
261-
"if you set endLocation, returnToDepot must be true. if returnToDepot is false, endLocationCoord must not be specified.");
260+
throw new IllegalArgumentException("You specified both the end location and that the vehicle " + id + " does not need to return to its end location. This must not be. " +
261+
"Either specify end location and return to depot or leave end location unspecified.");
262262
}
263263
if (startLocation != null && endLocation == null) {
264264
endLocation = startLocation;
265265
}
266266
if (startLocation == null && endLocation == null)
267-
throw new IllegalArgumentException("vehicle requires startLocation. but neither locationId nor locationCoord nor startLocationId nor startLocationCoord has been set");
267+
throw new IllegalArgumentException("Every vehicle requires a start location, but vehicle " + id + " does not have one.");
268268
skills = skillBuilder.build();
269269
return new VehicleImpl(this);
270270
}

0 commit comments

Comments
 (0)