Skip to content

Commit 02a7fe7

Browse files
committed
Correctly catch HttpException when retrieving item
Fixes #3779 Signed-off-by: Danny Baumann <[email protected]>
1 parent a783be8 commit 02a7fe7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mobile/src/main/java/org/openhab/habdroid/background/ItemsControlsProviderService.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ class ItemsControlsProviderService : ControlsProviderService() {
120120
}
121121
val state = when (action) {
122122
is BooleanAction -> {
123-
val item = ItemClient.loadItem(connection, itemName) ?: return ControlAction.RESPONSE_FAIL
123+
val item = try {
124+
ItemClient.loadItem(connection, itemName)
125+
} catch (e: HttpClient.HttpException) {
126+
Log.e(TAG, "Could not determine item type for boolean action", e)
127+
null
128+
} ?: return ControlAction.RESPONSE_FAIL
129+
124130
if (item.isOfTypeOrGroupType(Item.Type.Player)) {
125131
if (action.newState) "PLAY" else "PAUSE"
126132
} else {

0 commit comments

Comments
 (0)