Skip to content

Commit 9fe021d

Browse files
Remove OtpError implementation
1 parent a0f261c commit 9fe021d

File tree

4 files changed

+12
-50
lines changed

4 files changed

+12
-50
lines changed

application/src/main/java/org/opentripplanner/updater/spi/DataValidationExceptionMapper.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import org.opentripplanner.transit.model.framework.DataValidationException;
55
import org.opentripplanner.transit.model.framework.Result;
66
import org.opentripplanner.transit.model.timetable.TimetableValidationError;
7-
import org.opentripplanner.updater.trip.gtfs.model.InvalidTripError;
87
import org.slf4j.Logger;
98
import org.slf4j.LoggerFactory;
109

@@ -29,9 +28,6 @@ public static <T> Result<T, UpdateError> toResult(
2928
new UpdateError(tt.trip().getId(), mapTimeTableError(tt.code()), tt.stopIndex(), producer)
3029
);
3130
}
32-
if (error.error() instanceof InvalidTripError e) {
33-
return Result.failure(new UpdateError(e.tripId(), e.code(), null, producer));
34-
}
3531
// The mapper should handle all possible errors
3632
LOG.error("Unhandled error: {}", error.getMessage(), error);
3733
return Result.failure(UpdateError.noTripId(UpdateError.UpdateErrorType.UNKNOWN));

application/src/main/java/org/opentripplanner/updater/trip/gtfs/GtfsRealTimeTripUpdateAdapter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,12 @@ public UpdateResult applyTripUpdates(
146146
rawTripUpdate = rawTripUpdate.toBuilder().setTrip(trip).build();
147147
}
148148

149-
// throws exception when invalid
150149
var tripUpdate = new TripUpdate(feedId, rawTripUpdate, localDateNow);
150+
var validationResult = tripUpdate.validate();
151+
if (validationResult.isFailure()) {
152+
results.add(validationResult.toFailureResult());
153+
continue;
154+
}
151155

152156
// Determine what kind of trip update this is
153157
var scheduleRelationship = tripUpdate.scheduleRelationship();

application/src/main/java/org/opentripplanner/updater/trip/gtfs/model/InvalidTripError.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

application/src/main/java/org/opentripplanner/updater/trip/gtfs/model/TripUpdate.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import org.opentripplanner.core.model.id.FeedScopedId;
1616
import org.opentripplanner.transit.model.basic.Accessibility;
1717
import org.opentripplanner.transit.model.framework.DataValidationException;
18+
import org.opentripplanner.transit.model.framework.Result;
19+
import org.opentripplanner.updater.spi.UpdateError;
20+
import org.opentripplanner.updater.spi.UpdateSuccess;
1821

1922
/**
2023
* A real-time update for trip, which may contain updated stop times and trip properties.
@@ -37,7 +40,6 @@ public TripUpdate(
3740
this.tripUpdate = tripUpdate;
3841
this.tripDescriptor = new TripDescriptor(tripUpdate.getTrip());
3942
this.localDateNow = localDateNow;
40-
this.validate();
4143
}
4244

4345
public TripDescriptor descriptor() {
@@ -105,16 +107,17 @@ public FeedScopedId tripId() {
105107
);
106108
}
107109

108-
private void validate() throws DataValidationException {
110+
public Result<UpdateSuccess, UpdateError> validate() throws DataValidationException {
109111
if (tripDescriptor.tripId().isEmpty()) {
110-
throw new DataValidationException(new InvalidTripError(null, INVALID_INPUT_STRUCTURE));
112+
return Result.failure(UpdateError.noTripId(INVALID_INPUT_STRUCTURE));
111113
}
112114

113115
try {
114116
tripDescriptor.startDate();
115117
} catch (ParseException e) {
116-
throw new DataValidationException(new InvalidTripError(tripId(), INVALID_INPUT_STRUCTURE));
118+
return Result.failure(new UpdateError(tripId(), INVALID_INPUT_STRUCTURE));
117119
}
120+
return Result.success(UpdateSuccess.noWarnings());
118121
}
119122

120123
public Optional<FeedScopedId> routeId() {

0 commit comments

Comments
 (0)