diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/base/BaseViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/base/BaseViewModel.kt index fc013dd6..a9dbc35e 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/base/BaseViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/base/BaseViewModel.kt @@ -16,11 +16,11 @@ import kotlinx.coroutines.launch abstract class BaseViewModel : ViewModel() { val handler = CoroutineExceptionHandler { _, throwable -> viewModelScope.launch { - _errorEvent.emit(ErrorEvent(throwable)) + _errorEvent.emit(ErrorEvent.Client(throwable)) } } - private val _errorEvent: MutableEventFlow = MutableEventFlow() + protected val _errorEvent: MutableEventFlow = MutableEventFlow() val errorEvent: EventFlow = _errorEvent.asEventFlow() fun launch(block: suspend CoroutineScope.() -> Unit) { diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/base/ErrorEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/base/ErrorEvent.kt index 176b0d8c..ebdd89f6 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/base/ErrorEvent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/base/ErrorEvent.kt @@ -1,5 +1,11 @@ package ac.dnd.bookkeeping.android.presentation.common.base -data class ErrorEvent( - val throwable: Throwable -) +import ac.dnd.bookkeeping.android.domain.model.error.ServerException + +sealed class ErrorEvent( + open val exception: Throwable +) { + data class Client(override val exception: Throwable) : ErrorEvent(exception) + data class InvalidRequest(override val exception: ServerException) : ErrorEvent(exception) + data class UnavailableServer(override val exception: Throwable) : ErrorEvent(exception) +} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/util/ComposeUtil.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/util/ComposeUtil.kt index e50f578f..df18b494 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/util/ComposeUtil.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/util/ComposeUtil.kt @@ -2,6 +2,7 @@ package ac.dnd.bookkeeping.android.presentation.common.util import ac.dnd.bookkeeping.android.presentation.R import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel +import ac.dnd.bookkeeping.android.presentation.common.base.ErrorEvent import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.eventObserve import ac.dnd.bookkeeping.android.presentation.common.view.DialogScreen import androidx.compose.runtime.Composable @@ -26,23 +27,48 @@ import kotlin.coroutines.EmptyCoroutineContext fun ErrorObserver( viewModel: BaseViewModel ) { - var isDialogShowing by remember { mutableStateOf(false) } + var _error: ErrorEvent? by remember { mutableStateOf(null) } + val error = _error - if (isDialogShowing) { - DialogScreen( - title = stringResource(id = R.string.error_dialog_title), - onDismissRequest = { - isDialogShowing = false - } - ) + when (error) { + is ErrorEvent.Client -> { + DialogScreen( + title = stringResource(id = R.string.error_dialog_client_title), + message = stringResource(id = R.string.error_dialog_client_content), + onDismissRequest = { + _error = null + } + ) + } + + is ErrorEvent.InvalidRequest -> { + DialogScreen( + title = stringResource(id = R.string.error_dialog_invalid_request_title), + message = error.exception.message, + onDismissRequest = { + _error = null + } + ) + } + + is ErrorEvent.UnavailableServer -> { + DialogScreen( + title = stringResource(id = R.string.error_dialog_unavailable_server_title), + message = stringResource(id = R.string.error_dialog_unavailable_server_content), + onDismissRequest = { + _error = null + } + ) + } + + else -> Unit } LaunchedEffectWithLifecycle(viewModel.errorEvent) { viewModel.errorEvent.eventObserve { event -> - Timber.d(event.throwable) - Sentry.captureException(event.throwable) - - isDialogShowing = true + _error = event + Timber.d(event.exception) + Sentry.captureException(event.exception) } } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupEvent.kt index 3b22bb3f..32755f6d 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupEvent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupEvent.kt @@ -1,11 +1,7 @@ package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.group -import ac.dnd.bookkeeping.android.domain.model.error.ServerException - sealed interface AddGroupEvent { sealed interface AddGroup : AddGroupEvent { data object Success : AddGroup - data class Failure(val exception: ServerException) : AddGroup - data class Error(val exception: Throwable) : AddGroup } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupScreen.kt index d412af95..b23e2fe3 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupScreen.kt @@ -89,14 +89,6 @@ private fun AddGroupScreen( onResult() onDismissRequest() } - - is AddGroupEvent.AddGroup.Failure -> { - // TODO : ERROR - } - - is AddGroupEvent.AddGroup.Error -> { - // TODO : ERROR - } } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupViewModel.kt index 07437871..a1a28ff3 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupViewModel.kt @@ -3,6 +3,7 @@ package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.group import ac.dnd.bookkeeping.android.domain.model.error.ServerException import ac.dnd.bookkeeping.android.domain.usecase.feature.group.AddGroupUseCase import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel +import ac.dnd.bookkeeping.android.presentation.common.base.ErrorEvent import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.asEventFlow @@ -46,11 +47,11 @@ class AddGroupViewModel @Inject constructor( _state.value = AddGroupState.Init when (exception) { is ServerException -> { - _event.emit(AddGroupEvent.AddGroup.Failure(exception)) + _errorEvent.emit(ErrorEvent.InvalidRequest(exception)) } else -> { - _event.emit(AddGroupEvent.AddGroup.Error(exception)) + _errorEvent.emit(ErrorEvent.UnavailableServer(exception)) } } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationEvent.kt index 3e583dc8..65a5480b 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationEvent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationEvent.kt @@ -1,10 +1,3 @@ package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.relation -import ac.dnd.bookkeeping.android.domain.model.error.ServerException - -sealed interface SearchRelationEvent { - sealed interface GetGroup : SearchRelationEvent { - data class Failure(val exception: ServerException) : GetGroup - data class Error(val exception: Throwable) : GetGroup - } -} +sealed interface SearchRelationEvent diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationScreen.kt index 75f5bafb..e47bfd86 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationScreen.kt @@ -13,12 +13,14 @@ import ac.dnd.bookkeeping.android.presentation.common.theme.Headline2 import ac.dnd.bookkeeping.android.presentation.common.theme.Headline3 import ac.dnd.bookkeeping.android.presentation.common.theme.Primary4 import ac.dnd.bookkeeping.android.presentation.common.theme.Shapes +import ac.dnd.bookkeeping.android.presentation.common.util.ErrorObserver import ac.dnd.bookkeeping.android.presentation.common.util.LaunchedEffectWithLifecycle import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.eventObserve import ac.dnd.bookkeeping.android.presentation.common.view.BottomSheetScreen import ac.dnd.bookkeeping.android.presentation.common.view.CustomTextField +import ac.dnd.bookkeeping.android.presentation.common.view.DialogScreen import ac.dnd.bookkeeping.android.presentation.common.view.confirm.ConfirmButton import ac.dnd.bookkeeping.android.presentation.common.view.confirm.ConfirmButtonProperties import ac.dnd.bookkeeping.android.presentation.common.view.confirm.ConfirmButtonSize @@ -55,6 +57,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel @@ -79,6 +82,17 @@ fun SearchRelationScreen( groups = groups ) } + ErrorObserver(viewModel) + + var isDialogShowing by remember { mutableStateOf(false) } + + DialogScreen( + isShowing = isDialogShowing, + title = stringResource(id = R.string.error_dialog_title), + onDismissRequest = { + isDialogShowing = false + } + ) SearchRelationScreen( appState = appState, @@ -117,18 +131,6 @@ private fun SearchRelationScreen( // appState.navController.navigate(EditRelationConstant.ROUTE) } - fun getGroup(event: SearchRelationEvent.GetGroup) { - when (event) { - is SearchRelationEvent.GetGroup.Failure -> { - // TODO : ERROR - } - - is SearchRelationEvent.GetGroup.Error -> { - // TODO : ERROR - } - } - } - BottomSheetScreen( onDismissRequest = onDismissRequest, properties = BottomSheetDialogProperties( @@ -228,9 +230,7 @@ private fun SearchRelationScreen( LaunchedEffectWithLifecycle(event, handler) { event.eventObserve { event -> - when (event) { - is SearchRelationEvent.GetGroup -> getGroup(event) - } + } } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationViewModel.kt index 4403b4ae..0080df7b 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationViewModel.kt @@ -4,6 +4,7 @@ import ac.dnd.bookkeeping.android.domain.model.error.ServerException import ac.dnd.bookkeeping.android.domain.model.feature.group.GroupWithRelation import ac.dnd.bookkeeping.android.domain.usecase.feature.group.GetGroupListWithRelationUseCase import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel +import ac.dnd.bookkeeping.android.presentation.common.base.ErrorEvent import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.asEventFlow @@ -39,11 +40,11 @@ class SearchRelationViewModel @Inject constructor( }.onFailure { exception -> when (exception) { is ServerException -> { - _event.emit(SearchRelationEvent.GetGroup.Failure(exception)) + _errorEvent.emit(ErrorEvent.InvalidRequest(exception)) } else -> { - _event.emit(SearchRelationEvent.GetGroup.Error(exception)) + _errorEvent.emit(ErrorEvent.UnavailableServer(exception)) } } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryViewModel.kt index ac5cadb0..5fd24343 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryViewModel.kt @@ -4,6 +4,7 @@ import ac.dnd.bookkeeping.android.domain.model.error.ServerException import ac.dnd.bookkeeping.android.domain.model.legacy.HistoryInfoLegacy import ac.dnd.bookkeeping.android.domain.usecase.legacy.GetHistoryInfoUseCase import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel +import ac.dnd.bookkeeping.android.presentation.common.base.ErrorEvent import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.asEventFlow @@ -42,13 +43,13 @@ class HistoryViewModel @Inject constructor( } .onFailure { exception -> when (exception) { - is ServerException -> _event.emit( - HistoryMainEvent.GetHistoryInfoMain.Failure( - exception - ) - ) + is ServerException -> { + _errorEvent.emit(ErrorEvent.InvalidRequest(exception)) + } - else -> _event.emit(HistoryMainEvent.GetHistoryInfoMain.Error(exception)) + else -> { + _errorEvent.emit(ErrorEvent.UnavailableServer(exception)) + } } } _state.value = HistoryMainState.Init diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainEvent.kt index 0c0d462b..0f7f90f3 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainEvent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainEvent.kt @@ -1,10 +1,3 @@ package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main -import ac.dnd.bookkeeping.android.domain.model.error.ServerException - -sealed interface HistoryMainEvent { - sealed interface GetHistoryInfoMain : HistoryMainEvent { - data class Failure(val exception: ServerException) : GetHistoryInfoMain - data class Error(val exception: Throwable) : GetHistoryInfoMain - } -} +sealed interface HistoryMainEvent diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainScreen.kt index 299a2640..dc15421b 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainScreen.kt @@ -173,11 +173,7 @@ fun HistoryMainScreen( LaunchedEffectWithLifecycle(event, handler) { event.eventObserve { event -> - when (event) { - is HistoryMainEvent.GetHistoryInfoMain -> { - } - } } } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailEvent.kt index 23ad39f5..11909fce 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailEvent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailEvent.kt @@ -1,10 +1,3 @@ package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail -import ac.dnd.bookkeeping.android.domain.model.error.ServerException - -sealed interface HistoryDetailEvent { - sealed interface GetHistoryRelationList : HistoryDetailEvent { - data class Failure(val exception: ServerException) : GetHistoryRelationList - data class Error(val exception: Throwable) : GetHistoryRelationList - } -} +sealed interface HistoryDetailEvent diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailViewModel.kt index 97fb3010..9c3897e0 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailViewModel.kt @@ -4,6 +4,7 @@ import ac.dnd.bookkeeping.android.domain.model.error.ServerException import ac.dnd.bookkeeping.android.domain.model.legacy.GroupLegacy import ac.dnd.bookkeeping.android.domain.usecase.legacy.GetHistoryGroupListUseCase import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel +import ac.dnd.bookkeeping.android.presentation.common.base.ErrorEvent import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.asEventFlow @@ -57,11 +58,11 @@ class HistoryDetailViewModel @Inject constructor( .onFailure { exception -> when (exception) { is ServerException -> { - _event.emit(HistoryDetailEvent.GetHistoryRelationList.Failure(exception)) + _errorEvent.emit(ErrorEvent.InvalidRequest(exception)) } else -> { - _event.emit(HistoryDetailEvent.GetHistoryRelationList.Error(exception)) + _errorEvent.emit(ErrorEvent.UnavailableServer(exception)) } } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainViewModel.kt index 3a501342..2a8bbc72 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/login/main/LoginMainViewModel.kt @@ -93,14 +93,14 @@ class LoginMainViewModel @Inject constructor( } } - private fun submitError(error: Throwable) = launch { - when (error) { + private fun submitError(exception: Throwable) = launch { + when (exception) { is ServerException -> { - _event.emit(LoginMainEvent.Login.Failure(error)) + _event.emit(LoginMainEvent.Login.Failure(exception)) } else -> { - _event.emit(LoginMainEvent.Login.Error(error)) + _event.emit(LoginMainEvent.Login.Error(exception)) } } _state.emit(LoginMainState.Init) diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/registration/main/RegistrationMainViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/registration/main/RegistrationMainViewModel.kt index f85c3f05..36993173 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/registration/main/RegistrationMainViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/registration/main/RegistrationMainViewModel.kt @@ -4,6 +4,7 @@ import ac.dnd.bookkeeping.android.domain.model.error.ServerException import ac.dnd.bookkeeping.android.domain.usecase.authentication.RegistrationUseCase import ac.dnd.bookkeeping.android.domain.usecase.member.CheckNicknameUseCase import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel +import ac.dnd.bookkeeping.android.presentation.common.base.ErrorEvent import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.asEventFlow diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/splash/SplashEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/splash/SplashEvent.kt index 1b134e39..57310c58 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/splash/SplashEvent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/splash/SplashEvent.kt @@ -6,6 +6,5 @@ sealed interface SplashEvent { sealed interface Login : SplashEvent { data object Success : Login data class Failure(val exception: ServerException) : Login - data class Error(val exception: Throwable) : Login } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/splash/SplashScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/splash/SplashScreen.kt index 67976eda..162a5358 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/splash/SplashScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/splash/SplashScreen.kt @@ -58,10 +58,6 @@ fun SplashScreen( is SplashEvent.Login.Failure -> { navigateToLogin() } - - is SplashEvent.Login.Error -> { - // TODO : Unknown Error (Client Error, Internal Server Error, ...) - } } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/splash/SplashViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/splash/SplashViewModel.kt index 22c1608b..1ab8aa20 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/splash/SplashViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/splash/SplashViewModel.kt @@ -3,6 +3,7 @@ package ac.dnd.bookkeeping.android.presentation.ui.main.splash import ac.dnd.bookkeeping.android.domain.model.error.ServerException import ac.dnd.bookkeeping.android.domain.usecase.authentication.UpdateJwtTokenUseCase import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel +import ac.dnd.bookkeeping.android.presentation.common.base.ErrorEvent import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.asEventFlow @@ -49,7 +50,7 @@ class SplashViewModel @Inject constructor( } else -> { - _event.emit(SplashEvent.Login.Error(exception)) + _errorEvent.emit(ErrorEvent.UnavailableServer(exception)) } } } diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 6a4803c4..a43c7bca 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -7,7 +7,11 @@ 확인 취소 - 앗, 에러가 발생했어요! + 클라이언트 에러 + 앗, 에러가 발생했어요! + 요청 에러 + 서버 에러 + 현재 서버와의 접속이 원활하지 않습니다.\n잠시 후 다시 진행해주세요. 테스트 확인