Skip to content
Snippets Groups Projects
Unverified Commit 6bb04c49 authored by Juraj Kusnier's avatar Juraj Kusnier Committed by GitHub
Browse files

More human readable server errors (EXPOSUREAPP-7136) (#3143)

* human readable CwaServerError

* fix code formatting
parent 6822174d
No related branches found
No related tags found
No related merge requests found
package de.rki.coronawarnapp.exception.http package de.rki.coronawarnapp.exception.http
import android.content.Context
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.exception.reporting.ErrorCodes import de.rki.coronawarnapp.exception.reporting.ErrorCodes
import de.rki.coronawarnapp.exception.reporting.ReportedIOException import de.rki.coronawarnapp.exception.reporting.ReportedIOException
import de.rki.coronawarnapp.util.HasHumanReadableError
import de.rki.coronawarnapp.util.HumanReadableError
open class CwaWebException( open class CwaWebException(
val statusCode: Int, val statusCode: Int,
...@@ -21,12 +25,19 @@ open class CwaServerError( ...@@ -21,12 +25,19 @@ open class CwaServerError(
statusCode = statusCode, statusCode = statusCode,
message = message, message = message,
cause = cause cause = cause
) { ),
HasHumanReadableError {
init { init {
if (statusCode !in 500..599) { if (statusCode !in 500..599) {
throw IllegalArgumentException("Invalid HTTP server error code $statusCode (!= 5xx)") throw IllegalArgumentException("Invalid HTTP server error code $statusCode (!= 5xx)")
} }
} }
override fun toHumanReadableError(context: Context): HumanReadableError {
return HumanReadableError(
description = context.getString(R.string.submission_error_dialog_web_generic_network_error_body)
)
}
} }
open class CwaClientError( open class CwaClientError(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment