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

Loading…
Cancel
Save