Skip to content

Commit

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

Signed-off-by: Danny Baumann <dannybaumann@web.de>
  • Loading branch information
maniac103 authored Aug 15, 2024
1 parent 96b6861 commit a1a1c86
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 a1a1c86

Please sign in to comment.