Skip to content

Commit

Permalink
이미 종료된 채팅에 대한 결과 확인 에러 처리 보완
Browse files Browse the repository at this point in the history
TODO: 좀 더 보완할 수 있음
  • Loading branch information
easyhooon committed Nov 15, 2023
1 parent 5909835 commit 8d677ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,16 @@ internal class ChatRemoteDataSourceImpl @Inject constructor(
val response = service.endChatSession(endChatRequest)
if (response.isSuccessful) {
return response.body()
} else if (response.code() == 500) {
throw EndChatSessionResponseServerError
} else {
if (response.code() == 500) {
throw EndChatSessionResponseServerError
} else {
val errorBody = response.errorBody()?.string() ?: "Unknown error"
Timber.d(Exception(errorBody))
throw ExceptionWrapper(
statusCode = response.code(),
message = Exception(errorBody).toAlertMessage(),
cause = Exception(errorBody),
)
}
val errorBody = response.errorBody()?.string() ?: "Unknown error"
Timber.d(Exception(errorBody))
throw ExceptionWrapper(
statusCode = response.code(),
message = Exception(errorBody).toAlertMessage(),
cause = Exception(errorBody),
)
}
} catch (exception: HttpException) {
Timber.d(exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,10 @@ class ChatViewModel @Inject constructor(
}
result.isFailure -> {
val exception = result.exceptionOrNull()!!
if (exception == EndChatSessionResponseServerError) {
if (exception.cause == EndChatSessionResponseServerError) {
_eventFlow.emit(ChatUiEvent.ShowToast(UiText.StringResource(R.string.already_end_chat_session)))
} else {
_eventFlow.emit(ChatUiEvent.ShowToast(UiText.DirectString(exception.message.toString())))
// _eventFlow.emit(ChatUiEvent.ShowToast(UiText.StringResource(R.string.already_end_chat_session)))
}
}
}
Expand Down

0 comments on commit 8d677ca

Please sign in to comment.