Skip to content

Commit

Permalink
core: add error when stdcm requests don't end with a stop
Browse files Browse the repository at this point in the history
  • Loading branch information
eckter committed Jul 2, 2024
1 parent e0f4f41 commit d6f255b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ public enum ErrorType {
InconsistentSpeedSection(
"speed_section",
"Speed section definition is nonsensical and cannot be used for simulation",
ErrorCause.USER);
ErrorCause.USER),
MissingLastSTDCMStop("missing_last_stdcm_stop", "Last step of stdcm request needs to be a stop", ErrorCause.USER);

public final String type;
public final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import fr.sncf.osrd.envelope_sim_infra.EnvelopeTrainPath
import fr.sncf.osrd.envelope_sim_infra.MRSP
import fr.sncf.osrd.graph.Pathfinding
import fr.sncf.osrd.graph.PathfindingEdgeLocationId
import fr.sncf.osrd.reporting.exceptions.ErrorType
import fr.sncf.osrd.reporting.exceptions.OSRDError
import fr.sncf.osrd.reporting.warnings.DiagnosticRecorderImpl
import fr.sncf.osrd.sim_infra.api.Block
Expand All @@ -35,7 +36,6 @@ import fr.sncf.osrd.utils.units.Offset
import fr.sncf.osrd.utils.units.meters
import fr.sncf.osrd.utils.units.seconds
import java.time.Duration.ofMillis
import java.util.HashSet
import org.takes.Request
import org.takes.Response
import org.takes.Take
Expand Down Expand Up @@ -174,7 +174,9 @@ class STDCMEndpointV2(private val infraManager: InfraManager) : Take {
}

private fun parseSteps(infra: FullInfra, pathItems: List<STDCMPathItem>): List<STDCMStep> {
assert(pathItems.last().stopDuration != null)
if (pathItems.last().stopDuration == null) {
throw OSRDError(ErrorType.MissingLastSTDCMStop)
}
return pathItems
.map {
STDCMStep(
Expand Down
3 changes: 2 additions & 1 deletion front/public/locales/en/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"default": "An error has occurred.",
"pageNotFound": "The page you are looking for does not exist.",
"core": {
"assert_error": "Assert error at {{file_location}}: {{assert_message}}"
"assert_error": "Assert error at {{file_location}}: {{assert_message}}",
"missing_last_stdcm_stop": "STDCM requests that don't end with a stop aren't currently supported"
},
"editoast": {
"attached": {
Expand Down
3 changes: 2 additions & 1 deletion front/public/locales/fr/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"default": "Une erreur est survenue.",
"pageNotFound": "La page que vous recherchez n'existe pas.",
"core": {
"assert_error": "Assertion échouée à {{file_location}}: {{assert_message}}"
"assert_error": "Assertion échouée à {{file_location}}: {{assert_message}}",
"missing_last_stdcm_stop": "Les requêtes STDCM ne finissant pas par un arrêt ne sont pas actuellement supportées"
},
"editoast": {
"attached": {
Expand Down

0 comments on commit d6f255b

Please sign in to comment.