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

Fix missing error dialog (DEV) (#1564)


* Fix task exceptions not being forwarded to our current error UI elements.

* Clean up old transaction names.

* Use simple class name as error tag.

* Prevent error reporting from triggering in unit tests due to static access.

* Move isUnitTest to CWDebug

Co-authored-by: default avatarharambasicluka <64483219+harambasicluka@users.noreply.github.com>
parent 22f36224
No related branches found
No related tags found
No related merge requests found
package de.rki.coronawarnapp.bugreporting package de.rki.coronawarnapp.bugreporting
import de.rki.coronawarnapp.util.CWADebug
import de.rki.coronawarnapp.util.di.AppInjector import de.rki.coronawarnapp.util.di.AppInjector
interface BugReporter { interface BugReporter {
...@@ -7,6 +8,7 @@ interface BugReporter { ...@@ -7,6 +8,7 @@ interface BugReporter {
} }
fun Throwable.reportProblem(tag: String? = null, info: String? = null) { fun Throwable.reportProblem(tag: String? = null, info: String? = null) {
if (CWADebug.isAUnitTest) return
val reporter = AppInjector.component.bugReporter val reporter = AppInjector.component.bugReporter
reporter.report(this, tag, info) reporter.report(this, tag, info)
} }
...@@ -10,6 +10,7 @@ import de.rki.coronawarnapp.exception.ExceptionCategory ...@@ -10,6 +10,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_API_FAIL
import de.rki.coronawarnapp.exception.reporting.ReportingConstants.STATUS_CODE_GOOGLE_UPDATE_NEEDED 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.exception.reporting.ReportingConstants.STATUS_CODE_REACHED_REQUEST_LIMIT
import de.rki.coronawarnapp.util.CWADebug
import de.rki.coronawarnapp.util.tryFormattedError import de.rki.coronawarnapp.util.tryFormattedError
import java.io.PrintWriter import java.io.PrintWriter
import java.io.StringWriter import java.io.StringWriter
...@@ -22,6 +23,8 @@ fun Throwable.report( ...@@ -22,6 +23,8 @@ fun Throwable.report(
prefix: String?, prefix: String?,
suffix: String? suffix: String?
) { ) {
if (CWADebug.isAUnitTest) return
reportProblem(tag = prefix, info = suffix) reportProblem(tag = prefix, info = suffix)
val context = CoronaWarnApplication.getAppContext() val context = CoronaWarnApplication.getAppContext()
......
package de.rki.coronawarnapp.task package de.rki.coronawarnapp.task
import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting
import de.rki.coronawarnapp.bugreporting.reportProblem
import de.rki.coronawarnapp.exception.ExceptionCategory
import de.rki.coronawarnapp.exception.reporting.report
import de.rki.coronawarnapp.task.TaskFactory.Config.CollisionBehavior import de.rki.coronawarnapp.task.TaskFactory.Config.CollisionBehavior
import de.rki.coronawarnapp.task.internal.InternalTaskState import de.rki.coronawarnapp.task.internal.InternalTaskState
import de.rki.coronawarnapp.util.TimeStamper import de.rki.coronawarnapp.util.TimeStamper
...@@ -147,6 +150,8 @@ class TaskController @Inject constructor( ...@@ -147,6 +150,8 @@ class TaskController @Inject constructor(
state.job.getCompleted() state.job.getCompleted()
} else { } else {
Timber.tag(TAG).e(error, "Task failed: %s", state) Timber.tag(TAG).e(error, "Task failed: %s", state)
error.report(ExceptionCategory.INTERNAL)
error.reportProblem(tag = state.request.type.simpleName)
null null
} }
......
package de.rki.coronawarnapp.transaction package de.rki.coronawarnapp.task.internal
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
...@@ -8,6 +8,6 @@ import javax.inject.Singleton ...@@ -8,6 +8,6 @@ import javax.inject.Singleton
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
@Singleton @Singleton
class TransactionCoroutineScope @Inject constructor() : CoroutineScope { class DefaultTaskCoroutineScope @Inject constructor() : CoroutineScope {
override val coroutineContext: CoroutineContext = SupervisorJob() + Dispatchers.Default override val coroutineContext: CoroutineContext = SupervisorJob() + Dispatchers.Default
} }
...@@ -4,7 +4,6 @@ import dagger.Module ...@@ -4,7 +4,6 @@ import dagger.Module
import dagger.Provides import dagger.Provides
import de.rki.coronawarnapp.task.TaskCoroutineScope import de.rki.coronawarnapp.task.TaskCoroutineScope
import de.rki.coronawarnapp.task.example.QueueingTaskModule import de.rki.coronawarnapp.task.example.QueueingTaskModule
import de.rki.coronawarnapp.transaction.TransactionCoroutineScope
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import javax.inject.Singleton import javax.inject.Singleton
...@@ -17,5 +16,5 @@ class TaskModule { ...@@ -17,5 +16,5 @@ class TaskModule {
@Provides @Provides
@Singleton @Singleton
@TaskCoroutineScope @TaskCoroutineScope
fun provideScope(scope: TransactionCoroutineScope): CoroutineScope = scope fun provideScope(scope: DefaultTaskCoroutineScope): CoroutineScope = scope
} }
...@@ -31,4 +31,13 @@ object CWADebug { ...@@ -31,4 +31,13 @@ object CWADebug {
DEVICE("device"), DEVICE("device"),
DEVICE_FOR_TESTERS("deviceForTesters") DEVICE_FOR_TESTERS("deviceForTesters")
} }
val isAUnitTest: Boolean by lazy {
try {
Class.forName("testhelpers.IsAUnitTest")
true
} catch (e: Exception) {
false
}
}
} }
package testhelpers
class IsAUnitTest
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