From ae0e5a7dd0753b66882f7e6806963c7dc3d9e307 Mon Sep 17 00:00:00 2001 From: skydoves Date: Thu, 19 Jan 2023 15:47:10 +0900 Subject: [PATCH] Improve an error message for onFailure extension --- .../feature/chat/messages/ChatGPTMessagesViewModel.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/feature-chat/src/main/kotlin/com/skydoves/chatgpt/feature/chat/messages/ChatGPTMessagesViewModel.kt b/feature-chat/src/main/kotlin/com/skydoves/chatgpt/feature/chat/messages/ChatGPTMessagesViewModel.kt index 38f14517..1cd44d65 100644 --- a/feature-chat/src/main/kotlin/com/skydoves/chatgpt/feature/chat/messages/ChatGPTMessagesViewModel.kt +++ b/feature-chat/src/main/kotlin/com/skydoves/chatgpt/feature/chat/messages/ChatGPTMessagesViewModel.kt @@ -29,7 +29,7 @@ import com.skydoves.chatgpt.core.navigation.ChatGPTScreens.Companion.argument_ch import com.skydoves.chatgpt.core.preferences.Empty import com.skydoves.sandwich.message import com.skydoves.sandwich.messageOrNull -import com.skydoves.sandwich.onError +import com.skydoves.sandwich.onFailure import com.skydoves.sandwich.suspendOnSuccess import dagger.hilt.android.lifecycle.HiltViewModel import io.getstream.chat.android.client.ChatClient @@ -93,10 +93,10 @@ class ChatGPTMessagesViewModel @Inject constructor( streamLog { "onResponse: $data" } messageItemSet.value -= text sendStreamMessage(data) - }.onError { + }.onFailure { + streamLog { "onFailure: $messageOrNull" } messageItemSet.value -= messageItemSet.value - mutableError.value = statusCode.toString() - streamLog { "Failure: $messageOrNull" } + mutableError.value = message() } } }