pref: 未登录异常
This commit is contained in:
parent
ac29cc0424
commit
8bcbbe8dfa
|
|
@ -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)
|
||||||
|
|
@ -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)
|
||||||
|
|
@ -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(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue