Skip to content

Commit e512f72

Browse files
committed
[CHORE] Description Add
1 parent edeef68 commit e512f72

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

app/src/main/java/com/lukaslechner/coroutineusecasesonandroid/usecases/coroutines/usecase1/MockApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fun mockApi() =
1111
.mock(
1212
"http://localhost/recent-android-versions",
1313
{ Gson().toJson(mockAndroidVersions) },
14-
404,
14+
200, //에러 터트리려면 400이상 날려야함
1515
150
1616
)
1717
)

app/src/main/java/com/lukaslechner/coroutineusecasesonandroid/usecases/coroutines/usecase1/PerformSingleNetworkRequestViewModel.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ class PerformSingleNetworkRequestViewModel(
1616
fun performSingleNetworkRequest() {
1717
viewModelScope.launch {
1818
uiState.value = UiState.Loading
19-
uiState.value = withContext(Dispatchers.IO) {
20-
kotlin.runCatching { UiState.Success(mockApi.getRecentAndroidVersions()) }
21-
.getOrElse { throwable ->
22-
when (throwable) {
23-
is HttpException -> UiState.Error("${throwable.code()} : ${throwable.message()}")
24-
else -> UiState.Error(throwable.message.toString())
25-
}
19+
uiState.value =
20+
runCatching {
21+
UiState.Success(mockApi.getRecentAndroidVersions())
22+
}.getOrElse { throwable ->
23+
when (throwable) {
24+
is HttpException -> UiState.Error("${throwable.code()} : ${throwable.message()}")
25+
else -> UiState.Error(throwable.message.toString())
2626
}
27-
}
27+
}
2828
}
2929
}
3030
}

0 commit comments

Comments
 (0)