Skip to content

Commit

Permalink
Correctly catch HttpException when retrieving item
Browse files Browse the repository at this point in the history
Fixes openhab#3779

Signed-off-by: Danny Baumann <[email protected]>
  • Loading branch information
maniac103 committed Aug 14, 2024
1 parent a783be8 commit d8690d0
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ class ItemsControlsProviderService : ControlsProviderService() {
}
val state = when (action) {
is BooleanAction -> {
val item = ItemClient.loadItem(connection, itemName) ?: return ControlAction.RESPONSE_FAIL
val item = try {
ItemClient.loadItem(connection, itemName)
} catch (e: HttpClient.HttpException) {
Log.e(TAG, "Could not determine item type for boolean action", e)
null
} ?: return ControlAction.RESPONSE_FAIL

if (item.isOfTypeOrGroupType(Item.Type.Player)) {
if (action.newState) "PLAY" else "PAUSE"
} else {
Expand Down

0 comments on commit d8690d0

Please sign in to comment.