throw Failure instead of meaning less IOException

This commit is contained in:
Benoit Marty 2019-09-25 11:27:23 +02:00
parent 4c04014e4d
commit f3039601bf

View file

@ -22,6 +22,7 @@ import com.squareup.moshi.Moshi
import im.vector.matrix.android.api.auth.data.SessionParams
import im.vector.matrix.android.internal.di.Authenticated
import im.vector.matrix.android.internal.network.ProgressRequestBody
import im.vector.matrix.android.internal.network.toFailure
import okhttp3.*
import java.io.File
import java.io.IOException
@ -74,7 +75,7 @@ internal class FileUploader @Inject constructor(@Authenticated
return Try {
okHttpClient.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
throw IOException()
throw response.toFailure()
} else {
response.body()?.source()?.let {
responseAdapter.fromJson(it)