Skip to content
Snippets Groups Projects
Unverified Commit 0f3a420d authored by Matthias Urhahn's avatar Matthias Urhahn Committed by GitHub
Browse files

Improve low storage error formatting (EXPOSUREAPP-2745) (#1292)


* Try to use formatted error messages if available.

* Try to use formatted error messages if available.

* If there is no fallback appconfig yet, abort early to show a more accurate error (download error vs "no app config" error).

* Revert "If there is no fallback appconfig yet, abort early to show a more accurate error (download error vs "no app config" error)."

This reverts commit 10ff8f4f

Co-authored-by: default avatarharambasicluka <64483219+harambasicluka@users.noreply.github.com>
parent a07897d5
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ import de.rki.coronawarnapp.exception.ExceptionCategory
import de.rki.coronawarnapp.exception.reporting.ReportingConstants.STATUS_CODE_GOOGLE_API_FAIL
import de.rki.coronawarnapp.exception.reporting.ReportingConstants.STATUS_CODE_GOOGLE_UPDATE_NEEDED
import de.rki.coronawarnapp.exception.reporting.ReportingConstants.STATUS_CODE_REACHED_REQUEST_LIMIT
import de.rki.coronawarnapp.util.tryFormattedError
import java.io.PrintWriter
import java.io.StringWriter
......@@ -20,11 +21,13 @@ fun Throwable.report(
prefix: String?,
suffix: String?
) {
val context = CoronaWarnApplication.getAppContext()
val intent = Intent(ReportingConstants.ERROR_REPORT_LOCAL_BROADCAST_CHANNEL)
intent.putExtra(ReportingConstants.ERROR_REPORT_CATEGORY_EXTRA, exceptionCategory.name)
intent.putExtra(ReportingConstants.ERROR_REPORT_PREFIX_EXTRA, prefix)
intent.putExtra(ReportingConstants.ERROR_REPORT_SUFFIX_EXTRA, suffix)
intent.putExtra(ReportingConstants.ERROR_REPORT_MESSAGE_EXTRA, this.message)
intent.putExtra(ReportingConstants.ERROR_REPORT_MESSAGE_EXTRA, this.tryFormattedError(context))
if (this is ReportedExceptionInterface) {
intent.putExtra(ReportingConstants.ERROR_REPORT_CODE_EXTRA, this.code)
......@@ -62,7 +65,7 @@ fun Throwable.report(
}
intent.putExtra(ReportingConstants.ERROR_REPORT_STACK_EXTRA, stackExtra)
LocalBroadcastManager.getInstance(CoronaWarnApplication.getAppContext()).sendBroadcast(intent)
LocalBroadcastManager.getInstance(context).sendBroadcast(intent)
}
fun reportGeneric(
......
......@@ -8,5 +8,5 @@ interface FormattedError {
fun Throwable.tryFormattedError(context: Context): String = when (this) {
is FormattedError -> this.getFormattedError(context)
else -> localizedMessage ?: this.toString()
else -> (localizedMessage ?: this.message) ?: this.toString()
}
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