Skip to content

Commit c993054

Browse files
david-allisonmikehardy
authored andcommitted
refactor: remove unused method
getCoroutineExceptionHandler (cherry picked from commit cc2c965)
1 parent 35e242e commit c993054

File tree

1 file changed

+0
-33
lines changed

1 file changed

+0
-33
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/CoroutineHelpers.kt

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import com.ichi2.utils.title
5252
import kotlinx.coroutines.CancellableContinuation
5353
import kotlinx.coroutines.CancellationException
5454
import kotlinx.coroutines.CoroutineDispatcher
55-
import kotlinx.coroutines.CoroutineExceptionHandler
5655
import kotlinx.coroutines.CoroutineScope
5756
import kotlinx.coroutines.Deferred
5857
import kotlinx.coroutines.Dispatchers
@@ -201,38 +200,6 @@ suspend fun <T> FragmentActivity.runCatching(
201200
return null
202201
}
203202

204-
/**
205-
* Returns CoroutineExceptionHandler which catches any uncaught exceptions and reports it to user
206-
* Errors from the backend contain localized text that is often suitable to show to the user as-is.
207-
* Other errors should ideally be handled in the block.
208-
*
209-
* Typically you'll want to use [launchCatchingTask] instead; this routine is mainly useful for
210-
* launching tasks in an activity that is not a lifecycleOwner.
211-
*
212-
* @return [CoroutineExceptionHandler]
213-
* @see [FragmentActivity.launchCatchingTask]
214-
*/
215-
fun getCoroutineExceptionHandler(
216-
activity: Activity,
217-
errorMessage: String? = null,
218-
) = CoroutineExceptionHandler { _, throwable ->
219-
// No need to check for cancellation-exception, it does not gets caught by CoroutineExceptionHandler
220-
when (throwable) {
221-
is BackendInterruptedException -> {
222-
Timber.e(throwable, errorMessage)
223-
throwable.localizedMessage?.let { activity.showSnackbar(it) }
224-
}
225-
is BackendException -> {
226-
Timber.e(throwable, errorMessage)
227-
activity.showError(throwable.localizedMessage!!, throwable.toCrashReportData(activity))
228-
}
229-
else -> {
230-
Timber.e(throwable, errorMessage)
231-
activity.showError(throwable)
232-
}
233-
}
234-
}
235-
236203
/**
237204
* Launch a job that catches any uncaught errors and reports them to the user.
238205
* Errors from the backend contain localized text that is often suitable to show to the user as-is.

0 commit comments

Comments
 (0)