From 03a32f09cf71287578c964bfd5819eaded60af00 Mon Sep 17 00:00:00 2001 From: Carlos Rafael Giani Date: Sun, 20 Nov 2022 18:31:44 +0100 Subject: [PATCH] comboctl-main: Catch getParsedDisplayFrame() exceptions and rethrow later Signed-off-by: Carlos Rafael Giani --- .../kotlin/info/nightscout/comboctl/main/RTNavigation.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/RTNavigation.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/RTNavigation.kt index 154bc75be5..6699a096c4 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/RTNavigation.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/RTNavigation.kt @@ -395,7 +395,16 @@ suspend fun longPressRTButtonUntil( rtNavigationContext.getParsedDisplayFrame(filterDuplicates = true) } } catch (e: TimeoutCancellationException) { + // Timeout expired, and we got no new frame. Stop waiting + // for one and continue long-pressing the button. We might + // be on a screen that does not update on its own. null + } catch (t: Throwable) { + // An exception that's not TimeoutCancellationException + // was thrown. Catch it, store it to rethrow it later, + // and end the long button press. + thrownDuringButtonPress = t + return@startLongButtonPress false } ?: return@startLongButtonPress true // It is possible that we got a parsed display frame very quickly.