Commit a94a3d82 authored by chenhuaqing's avatar chenhuaqing

error handling for vip expired

parent 8e6f0a36
...@@ -21,6 +21,7 @@ import okhttp3.RequestBody.Companion.toRequestBody ...@@ -21,6 +21,7 @@ import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response import okhttp3.Response
import timber.log.Timber import timber.log.Timber
import java.io.File import java.io.File
import java.io.IOException
import java.security.SecureRandom import java.security.SecureRandom
import java.security.cert.X509Certificate import java.security.cert.X509Certificate
import java.util.concurrent.Executors import java.util.concurrent.Executors
...@@ -83,6 +84,8 @@ object AuthManager { ...@@ -83,6 +84,8 @@ object AuthManager {
MMKV.defaultMMKV().putLong("LAST_ACC_TIME", last_acc_time) MMKV.defaultMMKV().putLong("LAST_ACC_TIME", last_acc_time)
} }
class AuthException(msg: String) : IOException(msg), BaseService.ExpectedException
suspend fun initAuthProfile(profile: Profile) { suspend fun initAuthProfile(profile: Profile) {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
getLineConfig()?.let { getLineConfig()?.let {
......
...@@ -124,7 +124,14 @@ class GuardedProcessPool(private val onFatal: suspend (IOException) -> Unit) : C ...@@ -124,7 +124,14 @@ class GuardedProcessPool(private val onFatal: suspend (IOException) -> Unit) : C
) { ) {
Guard(cmdSupplier).apply { Guard(cmdSupplier).apply {
launch { launch {
try {
start() // if start fails, IOException will be thrown directly start() // if start fails, IOException will be thrown directly
} catch (ex: Throwable) {
if (ex is AuthManager.AuthException) {
onFatal(ex)
return@launch
}
}
looper(onRestartCallback) looper(onRestartCallback)
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment