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
import android.content.Context
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.exception.reporting.ErrorCodes
import de.rki.coronawarnapp.exception.reporting.ReportedIOException
import de.rki.coronawarnapp.util.HasHumanReadableError
import de.rki.coronawarnapp.util.HumanReadableError
open class CwaWebException(
val statusCode: Int,
......@@ -21,12 +25,19 @@ open class CwaServerError(
statusCode = statusCode,
message = message,
cause = cause
) {
),
HasHumanReadableError {
init {
if (statusCode !in 500..599) {
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(
......
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