Exclude some Google Drive error reports

pull/1244/head
Alex Baker 5 years ago
parent 7bfd339021
commit 202a304139

@ -20,6 +20,7 @@ import timber.log.Timber
import java.io.FileNotFoundException
import java.io.IOException
import java.net.ConnectException
import java.net.SocketException
import java.net.SocketTimeoutException
import java.net.UnknownHostException
import javax.net.ssl.SSLException
@ -51,40 +52,45 @@ class DriveUploader @WorkerInject constructor(
.forEach { drive.delete(it) }
}
Result.success()
} catch (e: FileNotFoundException) {
fail(e)
} catch (e: SocketException) {
retry(e)
} catch (e: SocketTimeoutException) {
Timber.e(e)
Result.retry()
retry(e)
} catch (e: SSLException) {
Timber.e(e)
Result.retry()
retry(e)
} catch (e: ConnectException) {
Timber.e(e)
Result.retry()
retry(e)
} catch (e: UnknownHostException) {
Timber.e(e)
Result.retry()
} catch (e: FileNotFoundException) {
Timber.e(e)
Result.failure()
retry(e)
} catch (e: GoogleJsonResponseException) {
when (e.statusCode) {
401 -> {
Timber.e(e)
Result.failure()
401, 403 -> fail(e)
503 -> retry(e)
else -> retry(e, report = true)
}
503 -> {
Timber.e(e)
Result.retry()
} catch (e: IOException) {
fail(e, report = true)
}
else -> {
}
private fun fail(e: Throwable, report: Boolean = false): Result {
if (report) {
firebase.reportException(e)
Result.retry()
} else {
Timber.e(e)
}
return Result.failure()
}
} catch (e: IOException) {
private fun retry(e: Throwable, report: Boolean = false): Result {
if (report) {
firebase.reportException(e)
Result.failure()
} else {
Timber.e(e)
}
return Result.retry()
}
@Throws(IOException::class)

Loading…
Cancel
Save