NSCv1: catch misformatted devicestatus

This commit is contained in:
Milos Kozak 2023-10-27 21:48:24 +02:00
parent ff0d327a15
commit 4dde47bc44

View file

@ -524,7 +524,11 @@ class NSClientService : DaggerService() {
}
}
val devicestatuses = gson.fromJson(data.getString("devicestatus"), Array<NSDeviceStatus>::class.java)
val devicestatuses = try {
gson.fromJson(data.getString("devicestatus"), Array<NSDeviceStatus>::class.java)
} catch (unused: Exception) {
emptyArray<NSDeviceStatus>()
}
if (devicestatuses.isNotEmpty()) {
rxBus.send(EventNSClientNewLog("◄ DATA", "received " + devicestatuses.size + " device statuses"))
nsDeviceStatusHandler.handleNewData(devicestatuses)