pref: 未登录异常

This commit is contained in:
HuanCheng65 2023-03-11 00:02:32 +08:00
parent ac29cc0424
commit 8bcbbe8dfa
No known key found for this signature in database
GPG Key ID: E9031EF91A805148
3 changed files with 10 additions and 4 deletions

View File

@ -1,6 +1,6 @@
package com.huanchengfly.tieba.post.api.retrofit.exception package com.huanchengfly.tieba.post.api.retrofit.exception
class TiebaLocalException( open class TiebaLocalException(
override val code: Int, override val code: Int,
msg: String msg: String
) : TiebaException(msg) ) : TiebaException(msg)

View File

@ -0,0 +1,7 @@
package com.huanchengfly.tieba.post.api.retrofit.exception
import com.huanchengfly.tieba.post.api.Error.ERROR_NOT_LOGGED_IN
class TiebaNotLoggedInException(
msg: String = "Not logged in!"
) : TiebaLocalException(ERROR_NOT_LOGGED_IN, msg)

View File

@ -1,8 +1,7 @@
package com.huanchengfly.tieba.post.api.retrofit.interceptors package com.huanchengfly.tieba.post.api.retrofit.interceptors
import com.huanchengfly.tieba.post.api.Error.ERROR_NOT_LOGGED_IN
import com.huanchengfly.tieba.post.api.Header import com.huanchengfly.tieba.post.api.Header
import com.huanchengfly.tieba.post.api.retrofit.exception.TiebaLocalException import com.huanchengfly.tieba.post.api.retrofit.exception.TiebaNotLoggedInException
import com.huanchengfly.tieba.post.utils.AccountUtil import com.huanchengfly.tieba.post.utils.AccountUtil
import okhttp3.Interceptor import okhttp3.Interceptor
import okhttp3.Response import okhttp3.Response
@ -23,7 +22,7 @@ object ForceLoginInterceptor : Interceptor {
} }
if (forceLogin && !AccountUtil.isLoggedIn()) { if (forceLogin && !AccountUtil.isLoggedIn()) {
throw TiebaLocalException(ERROR_NOT_LOGGED_IN, "Not logged in.") throw TiebaNotLoggedInException()
} }
return chain.proceed( return chain.proceed(