Fix codeAnalysis errors

This commit is contained in:
Gergely Hegedus 2021-09-18 17:07:41 +03:00
parent 516b097e9e
commit 1aa0b48b0a
8 changed files with 37 additions and 13 deletions

View file

@ -14,11 +14,15 @@ internal class SessionAuthenticator(
private val networkSessionExpirationListener: NetworkSessionExpirationListener
) : Authenticator {
@Suppress("SwallowedException")
override fun authenticate(route: Route?, response: Response): Request? {
if (authenticationHeaderUtils.hasToken(response.request)) {
return runBlocking {
try {
val newSession = loginRemoteSource.refresh(networkSessionLocalStorage.session?.refreshToken.orEmpty())
val refreshToken = networkSessionLocalStorage.session
?.refreshToken
.orEmpty()
val newSession = loginRemoteSource.refresh(refreshToken)
networkSessionLocalStorage.session = newSession
return@runBlocking authenticationHeaderUtils.attachToken(response.request)
} catch (throwable: Throwable) {

View file

@ -8,6 +8,7 @@ import java.io.EOFException
internal object ExceptionWrapper {
@Suppress("RethrowCaughtException")
@Throws(NetworkException::class, ParsingException::class)
suspend fun <T> wrap(request: suspend () -> T) = try {
request()