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 fa230450f62..4b3f8e356a3 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 @@ -26,7 +26,7 @@ public enum ErrorType { StrictWarningError("strict_warning", "Warning was reported with strict mode enabled", ErrorCause.USER), AssertionError("assert_error", "assert check failed", ErrorCause.INTERNAL), UnknownError("unknown_error", "An unknown exception was thrown", ErrorCause.INTERNAL), - InfraSoftLoadingError("infra_loading:soft_error", "soft error while loading new infra", ErrorCause.USER, false), + InfraSoftLoadingError("infra_loading:soft_error", "soft error while loading new infra", ErrorCause.USER, true), InfraHardLoadingError("infra_loading:hard_error", "hard error while loading new infra", ErrorCause.USER), InfraHardError("infra:hard_error", "hard error while parsing infra", ErrorCause.USER), InfraLoadingCacheException("infra_loading:cache_exception", "cached exception", ErrorCause.INTERNAL), @@ -175,16 +175,16 @@ public enum ErrorType { public final String type; public final String message; public final ErrorCause cause; - public final boolean isCacheable; + public final boolean unrecoverable; ErrorType(String type, String message, ErrorCause cause) { - this(type, message, cause, true); + this(type, message, cause, false); } - ErrorType(String type, String message, ErrorCause cause, boolean isCacheable) { + ErrorType(String type, String message, ErrorCause cause, boolean unrecoverable) { this.type = "core:" + type; this.message = message; this.cause = cause; - this.isCacheable = isCacheable; + this.unrecoverable = unrecoverable; } } diff --git a/core/src/main/java/fr/sncf/osrd/api/ExceptionHandler.java b/core/src/main/java/fr/sncf/osrd/api/ExceptionHandler.java index 9952b9ee0ca..de39e1fde5d 100644 --- a/core/src/main/java/fr/sncf/osrd/api/ExceptionHandler.java +++ b/core/src/main/java/fr/sncf/osrd/api/ExceptionHandler.java @@ -1,7 +1,6 @@ package fr.sncf.osrd.api; import fr.sncf.osrd.reporting.exceptions.ErrorCause; -import fr.sncf.osrd.reporting.exceptions.ErrorType; import fr.sncf.osrd.reporting.exceptions.OSRDError; import org.takes.Response; import org.takes.rs.RsJson; @@ -15,7 +14,7 @@ public class ExceptionHandler { public static Response handle(Throwable ex) throws OSRDError { ex.printStackTrace(); if (ex instanceof OSRDError osrdError) { - if (osrdError.osrdErrorType == ErrorType.InfraSoftLoadingError) { + if (osrdError.osrdErrorType.unrecoverable) { throw osrdError; } return toResponse(osrdError); diff --git a/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/pathfinding/PathfindingBlocksEndpointV2.kt b/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/pathfinding/PathfindingBlocksEndpointV2.kt index b4ae7b2b7b1..d34c5c0016c 100644 --- a/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/pathfinding/PathfindingBlocksEndpointV2.kt +++ b/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/pathfinding/PathfindingBlocksEndpointV2.kt @@ -62,7 +62,7 @@ class PathfindingBlocksEndpointV2(private val infraManager: InfraManager) : Take pathfindingLogger.info("No path found") RsJson(RsWithBody(pathfindingResponseAdapter.toJson(error.response))) } catch (ex: Throwable) { - if (ex is OSRDError && ex.osrdErrorType.isCacheable) { + if (ex is OSRDError && !ex.osrdErrorType.unrecoverable) { pathfindingLogger.info("Pathfinding failed: ${ex.message}") val response = PathfindingFailed(ex) RsJson(RsWithBody(pathfindingResponseAdapter.toJson(response))) diff --git a/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/SimulationEndpoint.kt b/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/SimulationEndpoint.kt index 3f01b10720f..46743fb10dd 100644 --- a/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/SimulationEndpoint.kt +++ b/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/SimulationEndpoint.kt @@ -73,7 +73,7 @@ class SimulationEndpoint( ) return RsJson(RsWithBody(simulationResponseAdapter.toJson(res))) } catch (ex: Throwable) { - if (ex is OSRDError && ex.osrdErrorType.isCacheable) { + if (ex is OSRDError && !ex.osrdErrorType.unrecoverable) { val response = SimulationFailed(ex) return RsJson(RsWithBody(simulationResponseAdapter.toJson(response))) }