Skip to content

Commit

Permalink
core: cleanup error types and fix some causes
Browse files Browse the repository at this point in the history
  • Loading branch information
eckter committed Oct 13, 2023
1 parent 087973a commit d59ff34
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ public enum ErrorType {
InfraLoadingCacheException(
"infra_loading:cache_exception",
"cached exception",
ErrorCause.USER
ErrorCause.INTERNAL
),
InfraLoadingInvalidStatusException(
"infra_loading:invalid_status",
"Status doesn’t exist",
ErrorCause.USER
ErrorCause.INTERNAL
),
InfraInvalidStatusWhileWaitingStable(
"infra_loading:invalid_status_waiting_stable",
"invalid status after waitUntilStable",
ErrorCause.USER
ErrorCause.INTERNAL
),
InfraNotLoadedException(
"infra:not_loaded",
Expand Down Expand Up @@ -105,11 +105,6 @@ public enum ErrorType {
"Missing detectors on route (expected at least 2)",
ErrorCause.USER
),
InvalidInfraEndpointAlreadyLinked(
"invalid_infra:endpoint_already_linked",
"Error in track link: at least one endpoint is already linked",
ErrorCause.USER
),
InvalidInfraTrackSlopeWithInvalidRange(
"invalid_infra:track_slope_invalid_range",
"Track has a slope with an invalid range",
Expand Down Expand Up @@ -236,18 +231,6 @@ public enum ErrorType {
"Offset %s is not contained in the track ranges view",
ErrorCause.USER
),

InvalidRouteNoOffset(
"invalid_route",
"Couldn't find offset on route",
ErrorCause.USER
),

InvalidPathError(
"invalid_path",
"Detector offsets must be strictly increasing",
ErrorCause.USER
),
UnknownRollingStock(
"unknown_stock",
"unknown rolling stock",
Expand Down Expand Up @@ -296,12 +279,12 @@ public enum ErrorType {
EnvelopePartsNotContiguous(
"envelope_error",
"invalid envelope, envelope parts are not contiguous",
ErrorCause.USER
ErrorCause.INTERNAL
),
NoCompatibleEnvelopeFound(
"no_compatible_envelope",
"Couldn't find an envelope that wouldn't cause a conflict",
ErrorCause.USER
ErrorCause.INTERNAL
),
SignalingError(
"signaling_error",
Expand All @@ -318,16 +301,15 @@ public enum ErrorType {
"unknown sig schema field",
ErrorCause.USER
),

InvalidSTDCMDelayError(
"invalid_stdcm",
"STDCM lookahead isn't supported yet",
ErrorCause.USER
ErrorCause.INTERNAL
),
InvalidSTDCMUnspecifiedStartTime(
"invalid_stdcm",
"STDCM requests with unspecified start time are not supported yet",
ErrorCause.USER
ErrorCause.INTERNAL
),
InvalidSTDCMUnspecifiedStartAndEndTime(
"invalid_stdcm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,41 +195,6 @@ public static OSRDError newMissingRollingStockFieldError(
return error;
}

/**
* Creates a new OSRDError for an invalid schedule error with a track section.
*
* @param errorType the error type
* @param trackSection the track section associated with the error
* @return a new OSRDError instance
*/
public static OSRDError newInvalidScheduleError(
ErrorType errorType,
String trackSection
) {
var error = new OSRDError(errorType);
error.context.put("track_section", trackSection);
return error;
}

/**
* Creates a new OSRDError for an invalid schedule error with a route and route signaling type.
*
* @param errorType the error type
* @param route the route associated with the error
* @param routeSignalingType the route signaling type
* @return a new OSRDError instance
*/
public static OSRDError newInvalidScheduleError(
ErrorType errorType,
String route,
String routeSignalingType
) {
var error = new OSRDError(errorType);
error.context.put("route", route);
error.context.put("route_signaling_type", routeSignalingType);
return error;
}

/**
* Creates a new OSRDError for an invalid track range error with an offset.
*
Expand All @@ -244,23 +209,6 @@ public static OSRDError newInvalidTrackRangeError(
return error;
}

/**
* Creates a new OSRDError for an invalid path error with previous and current detectors.
*
* @param previousDetector the previous detector
* @param detector the current detector
* @return a new OSRDError instance
*/
public static OSRDError newInvalidPathError(
Object previousDetector,
Object detector
) {
var error = new OSRDError(ErrorType.InvalidPathError);
error.context.put("previous_detector", previousDetector);
error.context.put("detector", detector);
return error;
}

/**
* Creates a new OSRDError for an unknown rolling stock error with a rolling stock ID.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,6 @@ public static OSRDError newInvalidRangeError(ErrorType errorType, String id) {
return error;
}

/**
* Creates a new OSRDError for an invalid infrastructure error with a link ID and source/destination nodes.
*
* @param linkID the link ID associated with the error
* @param sourceNode the source node
* @param destinationNode the destination node
* @return a new OSRDError instance
*/
public static OSRDError newEndpointAlreadyLinkedError(
String linkID,
Object sourceNode,
Object destinationNode
) {
var error = new OSRDError(ErrorType.InvalidInfraEndpointAlreadyLinked);
error.context.put("link_id", linkID);
error.context.put("source_node", sourceNode);
error.context.put("destination_node", destinationNode);
return error;
}

/**
* Creates a new OSRDError for an invalid infrastructure error with an RJS switch ID, switch type, and switch ports.
*
Expand Down

0 comments on commit d59ff34

Please sign in to comment.