comboctl-main: Add more argument checks to Pump.connect()

Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
Carlos Rafael Giani 2022-11-20 23:04:30 +01:00
parent 605fe04d74
commit 90480ab1d9

View file

@ -899,6 +899,7 @@ class Pump(
*/
suspend fun connect(maxNumAttempts: Int? = DEFAULT_MAX_NUM_REGULAR_CONNECT_ATTEMPTS) {
check(stateFlow.value == State.Disconnected) { "Attempted to connect to pump in the ${stateFlow.value} state" }
check((maxNumAttempts == null) || (maxNumAttempts > 0))
val actualMaxNumAttempts = maxNumAttempts ?: Int.MAX_VALUE