Skip to content

Commit

Permalink
core: add error on zero length simulations
Browse files Browse the repository at this point in the history
Signed-off-by: Eloi Charpentier <[email protected]>
  • Loading branch information
eckter committed Feb 10, 2025
1 parent eeb8aa2 commit c8a0b05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public enum ErrorType {
"missing_route_from_chunk_path",
"couldn't find a route matching the given chunk list",
ErrorCause.INTERNAL),
ZeroLengthPath("zero_length_path", "can't simulate a zero length path", ErrorCause.USER),
;

public final String type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import fr.sncf.osrd.envelope_sim_infra.computeMRSP
import fr.sncf.osrd.external_generated_inputs.ElectricalProfileMapping
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.railjson.schema.schedule.RJSAllowanceDistribution
import fr.sncf.osrd.reporting.exceptions.ErrorType.ZeroLengthPath
import fr.sncf.osrd.reporting.exceptions.OSRDError
import fr.sncf.osrd.sim_infra.api.*
import fr.sncf.osrd.sim_infra.impl.ChunkPath
import fr.sncf.osrd.standalone_sim.result.ElectrificationRange
Expand Down Expand Up @@ -67,6 +69,7 @@ fun runStandaloneSimulation(
pathItemPositions: List<Offset<Path>>,
driverBehaviour: DriverBehaviour = DriverBehaviour()
): SimulationSuccess {
if (chunkPath.length == 0.meters) throw OSRDError(ZeroLengthPath)
// MRSP & SpeedLimits
val safetySpeedRanges = makeSafetySpeedRanges(infra, chunkPath, routes, schedule)
var mrsp =
Expand Down

0 comments on commit c8a0b05

Please sign in to comment.