@@ -52,7 +52,6 @@ import com.ichi2.utils.title
5252import kotlinx.coroutines.CancellableContinuation
5353import kotlinx.coroutines.CancellationException
5454import kotlinx.coroutines.CoroutineDispatcher
55- import kotlinx.coroutines.CoroutineExceptionHandler
5655import kotlinx.coroutines.CoroutineScope
5756import kotlinx.coroutines.Deferred
5857import 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