diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ErrorCodes.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ErrorCodes.kt index 5b89a01d3dd66e1dcc6cea51c4df0631dc69b712..de691a2a9770c24956e208496bddae1a00e15364 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ErrorCodes.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ErrorCodes.kt @@ -21,5 +21,6 @@ enum class ErrorCodes(val code: Int) { // NONTECHNICAL NO_NETWORK_CONNECTIVITY(1), NOT_ENOUGH_AVAILABLE_SPACE_ON_DISK(2), + API_EXCEPTION(3), EXTERNAL_NAVIGATION(10), } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ErrorReportReceiver.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ErrorReportReceiver.kt index d9e4be92bf3f856789644a2a70a95962dd8bc34d..ff37fe4dd14aa7619832cef0f90c268f0d5465aa 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ErrorReportReceiver.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ErrorReportReceiver.kt @@ -36,6 +36,14 @@ class ErrorReportReceiver(private val activity: Activity) : BroadcastReceiver() message = context.resources.getString(resId) } + if (intent.hasExtra(ReportingConstants.ERROR_REPORT_API_EXCEPTION_CODE)) { + val apiStatusCode = intent.getIntExtra( + ReportingConstants.ERROR_REPORT_API_EXCEPTION_CODE, + ErrorCodes.REPORTED_EXCEPTION_UNKNOWN_PROBLEM.code + ) + message += "($apiStatusCode)" + } + val stack = intent.getStringExtra(ReportingConstants.ERROR_REPORT_STACK_EXTRA) val title = context.resources.getString(R.string.errors_generic_headline) val confirm = context.resources.getString(R.string.errors_generic_button_positive) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ExceptionReporter.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ExceptionReporter.kt index 2031a593644cf760dfce34a2f4b0bd9ea1373c4b..3ad303932cb3a6902a1fdb803295bd63c1e9b895 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ExceptionReporter.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ExceptionReporter.kt @@ -2,7 +2,9 @@ package de.rki.coronawarnapp.exception.reporting import android.content.Intent import androidx.localbroadcastmanager.content.LocalBroadcastManager +import com.google.android.gms.common.api.ApiException import de.rki.coronawarnapp.CoronaWarnApplication +import de.rki.coronawarnapp.R import de.rki.coronawarnapp.exception.ExceptionCategory import java.io.PrintWriter import java.io.StringWriter @@ -26,6 +28,16 @@ fun Throwable.report( this.resId?.let { intent.putExtra(ReportingConstants.ERROR_REPORT_RES_ID, it) } } + // override the message with a generic one if it is an ApiException + if (this is ApiException) { + intent.putExtra( + ReportingConstants.ERROR_REPORT_RES_ID, + R.string.errors_communication_with_api + ) + intent.putExtra(ReportingConstants.ERROR_REPORT_CODE_EXTRA, ErrorCodes.API_EXCEPTION.code) + intent.putExtra(ReportingConstants.ERROR_REPORT_API_EXCEPTION_CODE, this.statusCode) + } + val sw = StringWriter() this.printStackTrace() this.printStackTrace(PrintWriter(sw)) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ReportingConstants.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ReportingConstants.kt index bf3bba6159798e3ea8d2f54c9c760ef07545f94a..be711c01353325bf57fb693ac16ecd82523456b6 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ReportingConstants.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ReportingConstants.kt @@ -8,6 +8,7 @@ object ReportingConstants { const val ERROR_REPORT_MESSAGE_EXTRA = "message" const val ERROR_REPORT_STACK_EXTRA = "stack" const val ERROR_REPORT_CODE_EXTRA = "code" + const val ERROR_REPORT_API_EXCEPTION_CODE = "api-exception-code" const val ERROR_REPORT_RES_ID = "res-id" val ERROR_REPORT_UNKNOWN_ERROR = ErrorCodes.REPORTED_EXCEPTION_UNKNOWN_PROBLEM.code }