Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💄 加了一个toast,提示查询同学课表次数过于频繁 #506

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ interface IApiStatus : Serializable {
userTokenService.refreshTokenExpired()
}
}
if (!isSuccess()) throw ApiException(status, info)
if (!isSuccess()) {
throw ApiException(status, info)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import io.reactivex.rxjava3.schedulers.Schedulers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import retrofit2.HttpException

/**
* ...
Expand Down Expand Up @@ -49,9 +50,15 @@ class FindStuViewModel : BaseViewModel() {
}.onCompletion {
// progressDialogEvent.value = ProgressDialogEvent.DISMISS_DIALOG_EVENT
}.mapOrThrowApiException()
.catch {
toast("网络似乎开小差了")
}.collectLaunch {
//数据请求有多次请求受限,这里检测出okhttp拦截下的异常为HttpException,异常码为429,所以这里对其进行处理
.catch { throwable ->
val code = (throwable as? HttpException)?.code()
if (code == 429)
toast("查询过于频繁,请稍后再试")
else
toast("网络似乎开小差了")
}
.collectLaunch {
_studentSearchData.emit(it)
}
}
Expand Down
Loading