From 453ffc5739e15b01465044f149e583b897fc38c5 Mon Sep 17 00:00:00 2001 From: Eloi Charpentier Date: Fri, 13 Oct 2023 10:57:21 +0200 Subject: [PATCH] core: cleanup error types and fix some causes --- .../osrd/reporting/exceptions/ErrorType.java | 30 +++-------- .../osrd/reporting/exceptions/OSRDError.java | 52 ------------------- .../undirected/UndirectedInfraBuilder.java | 20 ------- 3 files changed, 6 insertions(+), 96 deletions(-) diff --git a/core/osrd-reporting/src/main/java/fr/sncf/osrd/reporting/exceptions/ErrorType.java b/core/osrd-reporting/src/main/java/fr/sncf/osrd/reporting/exceptions/ErrorType.java index e6bc927c400..d8ef3fea7a4 100644 --- a/core/osrd-reporting/src/main/java/fr/sncf/osrd/reporting/exceptions/ErrorType.java +++ b/core/osrd-reporting/src/main/java/fr/sncf/osrd/reporting/exceptions/ErrorType.java @@ -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", @@ -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", @@ -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", @@ -296,7 +279,7 @@ public enum ErrorType { EnvelopePartsNotContiguous( "envelope_error", "invalid envelope, envelope parts are not contiguous", - ErrorCause.USER + ErrorCause.INTERNAL ), SignalingError( "signaling_error", @@ -313,16 +296,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", diff --git a/core/osrd-reporting/src/main/java/fr/sncf/osrd/reporting/exceptions/OSRDError.java b/core/osrd-reporting/src/main/java/fr/sncf/osrd/reporting/exceptions/OSRDError.java index 00df10c68fc..5a159834b10 100644 --- a/core/osrd-reporting/src/main/java/fr/sncf/osrd/reporting/exceptions/OSRDError.java +++ b/core/osrd-reporting/src/main/java/fr/sncf/osrd/reporting/exceptions/OSRDError.java @@ -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. * @@ -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. * diff --git a/core/src/main/java/fr/sncf/osrd/infra/implementation/tracks/undirected/UndirectedInfraBuilder.java b/core/src/main/java/fr/sncf/osrd/infra/implementation/tracks/undirected/UndirectedInfraBuilder.java index e0e59f8de22..17d20b41fc2 100644 --- a/core/src/main/java/fr/sncf/osrd/infra/implementation/tracks/undirected/UndirectedInfraBuilder.java +++ b/core/src/main/java/fr/sncf/osrd/infra/implementation/tracks/undirected/UndirectedInfraBuilder.java @@ -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. *