Skip to content
Snippets Groups Projects
Unverified Commit ca130d00 authored by Roman Elizarov's avatar Roman Elizarov Committed by GitHub
Browse files

Never report CancellationException (#1589)

There is a number of place in the app with the following code pattern:

try {
    // do some suspending operation
} catch(e: Exception) {
    e.report(ExceptionCategory.EXPOSURENOTIFICATION) // or similar
}

In all such place if the corresponding suspending gets cancelled for any reason, the resulting CancellationException will get reported as an application crash. This fix prevents it from happening, since a cancellation exception is a part of a normal operation, not a failure that should be reported.
parent eff2ad4d
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@ import de.rki.coronawarnapp.util.HasHumanReadableError
import de.rki.coronawarnapp.util.tryHumanReadableError
import java.io.PrintWriter
import java.io.StringWriter
import java.util.concurrent.CancellationException
fun Throwable.report(exceptionCategory: ExceptionCategory) =
this.report(exceptionCategory, null, null)
......@@ -26,6 +27,10 @@ fun Throwable.report(
) {
if (CWADebug.isAUnitTest) return
// CancellationException is a part of normal operation. It is used to cancel a running
// asynchronous operation. It is not a failure and should not be reported as such.
if (this is CancellationException) return
reportProblem(tag = prefix, info = suffix)
val context = CoronaWarnApplication.getAppContext()
......
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