Skip to content

Commit 015a3fd

Browse files
CopilotbedaHovorka
andcommitted
Replace assertion in RailSemaphore.kt
- Replaced 1 assertion in RailSemaphore.kt with requireSimulation - All original error messages preserved Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
1 parent e2cb8f3 commit 015a3fd

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/main/kotlin/cz/vutbr/fit/interlockSim/objects/cells/RailSemaphore.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
package cz.vutbr.fit.interlockSim.objects.cells
1111

12+
import cz.vutbr.fit.interlockSim.exceptions.requireSimulation
1213
import cz.vutbr.fit.interlockSim.objects.paths.PathElement
1314
import cz.vutbr.fit.interlockSim.sim.PathSeparatorChangeException
1415
import io.github.oshai.kotlinlogging.KotlinLogging
@@ -87,7 +88,9 @@ open class RailSemaphore(
8788
*/
8889
@JvmStatic
8990
fun forSpeed(speed: Double): Signal {
90-
assert(speed >= S30.allowedSpeed() || speed == 0.0)
91+
requireSimulation(speed >= S30.allowedSpeed() || speed == 0.0) {
92+
"Speed must be at least S30 allowed speed or 0.0: $speed"
93+
}
9194
for (s in values) {
9295
if (s.allowedSpeed() > speed) return if (s.ordinal == 0) STOP else values[s.ordinal - 1]
9396
}

0 commit comments

Comments
 (0)