From a5dec974103628da51627c9c0dc1ccbf8f84e29f Mon Sep 17 00:00:00 2001 From: onoderis Date: Sun, 3 Sep 2017 02:05:34 +0300 Subject: [PATCH] Handle exception when loading BTTV channel emoticons --- .../kotlin/failchat/core/AppStateTransitionManager.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/failchat/core/AppStateTransitionManager.kt b/src/main/kotlin/failchat/core/AppStateTransitionManager.kt index 43928dd2..550fb417 100644 --- a/src/main/kotlin/failchat/core/AppStateTransitionManager.kt +++ b/src/main/kotlin/failchat/core/AppStateTransitionManager.kt @@ -108,9 +108,13 @@ class AppStateTransitionManager(private val kodein: Kodein) { // load BTTV channel emoticons in background bttvApiClient.loadChannelEmoticons(channelName) - .thenAccept { - emoticonStorage.putCodeMapping(Origin.bttvChannel, it.map { it.code.toLowerCase() to it }.toMap()) - emoticonStorage.putList(Origin.bttvChannel, it) + .thenApply { emoticons -> + emoticonStorage.putCodeMapping(Origin.bttvChannel, emoticons.map { it.code.toLowerCase() to it }.toMap()) + emoticonStorage.putList(Origin.bttvChannel, emoticons) + log.info("BTTV emoticons loaded for channel '{}', count: {}", channelName, emoticons.size) + } + .exceptionally { e -> + log.warn("Failed to load BTTV emoticons for channel '{}'", channelName, e) } }