Skip to content

Commit d22e0e4

Browse files
committed
Refactor: 자동로그인 실패 시 예외처리
- 자동로그인 요청에 5초 timeout 설정 - 자동로그인 실패시 UserRole을 null로 설정
1 parent a868f00 commit d22e0e4

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

presentation/src/main/java/com/threegap/bitnagil/presentation/splash/SplashViewModel.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import com.threegap.bitnagil.presentation.splash.model.SplashState
1111
import dagger.hilt.android.lifecycle.HiltViewModel
1212
import kotlinx.coroutines.delay
1313
import kotlinx.coroutines.launch
14+
import kotlinx.coroutines.withTimeoutOrNull
1415
import org.orbitmvi.orbit.syntax.simple.SimpleSyntax
1516
import javax.inject.Inject
1617

@@ -62,8 +63,14 @@ class SplashViewModel @Inject constructor(
6263

6364
private fun performAutoLogin() {
6465
viewModelScope.launch {
65-
val userRole = autoLoginUseCase()
66-
sendIntent(SplashIntent.SetUserRole(userRole))
66+
try {
67+
val userRole = withTimeoutOrNull(5000) {
68+
autoLoginUseCase()
69+
}
70+
sendIntent(SplashIntent.SetUserRole(userRole))
71+
} catch (e: Exception) {
72+
sendIntent(SplashIntent.SetUserRole(null))
73+
}
6774
}
6875
}
6976

0 commit comments

Comments
 (0)