From e1423c0f82a2c56a7d7e1ac734c413ab80b24285 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 10 Jul 2022 20:48:19 +0200 Subject: [PATCH] catch serialization --- .../java/info/nightscout/shared/weardata/EventData.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt b/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt index aca2303c89..fd30835155 100644 --- a/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt +++ b/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt @@ -14,7 +14,11 @@ sealed class EventData : Event() { companion object { - fun deserialize(json: String) = Json.decodeFromString(serializer(), json) + fun deserialize(json: String) = try { + Json.decodeFromString(serializer(), json) + } catch (ignored: Exception) { + Error(System.currentTimeMillis()) + } } // Mobile <- Wear @@ -234,7 +238,7 @@ sealed class EventData : Event() { @Serializable // returnCommand is sent back to Mobile after confirmation data class ConfirmAction(val title: String, val message: String, val returnCommand: EventData?) : EventData() - + @Serializable data class SnoozeAlert(val timeStamp: Long) : EventData() }