mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
including the worker failure message in the logs and including throwable class name
This commit is contained in:
parent
6031c50313
commit
a56a7adb46
@ -53,7 +53,7 @@ internal class MultipleEventSendingDispatcherWorker(context: Context, params: Wo
|
|||||||
@Inject lateinit var timelineSendEventWorkCommon: TimelineSendEventWorkCommon
|
@Inject lateinit var timelineSendEventWorkCommon: TimelineSendEventWorkCommon
|
||||||
@Inject lateinit var localEchoRepository: LocalEchoRepository
|
@Inject lateinit var localEchoRepository: LocalEchoRepository
|
||||||
|
|
||||||
override fun doOnError(params: Params): Result {
|
override fun doOnError(params: Params, failureMessage: String): Result {
|
||||||
params.localEchoIds.forEach { localEchoIds ->
|
params.localEchoIds.forEach { localEchoIds ->
|
||||||
localEchoRepository.updateSendState(
|
localEchoRepository.updateSendState(
|
||||||
eventId = localEchoIds.eventId,
|
eventId = localEchoIds.eventId,
|
||||||
@ -63,7 +63,7 @@ internal class MultipleEventSendingDispatcherWorker(context: Context, params: Wo
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.doOnError(params)
|
return super.doOnError(params, failureMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun injectWith(injector: SessionComponent) {
|
override fun injectWith(injector: SessionComponent) {
|
||||||
|
@ -55,14 +55,16 @@ internal abstract class SessionSafeCoroutineWorker<PARAM : SessionWorkerParams>(
|
|||||||
|
|
||||||
// Make sure to inject before handling error as you may need some dependencies to process them.
|
// Make sure to inject before handling error as you may need some dependencies to process them.
|
||||||
injectWith(sessionComponent)
|
injectWith(sessionComponent)
|
||||||
if (params.lastFailureMessage != null) {
|
|
||||||
|
when (val lastFailureMessage = params.lastFailureMessage) {
|
||||||
|
null -> doSafeWork(params)
|
||||||
|
else -> {
|
||||||
// Forward error to the next workers
|
// Forward error to the next workers
|
||||||
doOnError(params)
|
doOnError(params, lastFailureMessage)
|
||||||
} else {
|
}
|
||||||
doSafeWork(params)
|
|
||||||
}
|
}
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
buildErrorResult(params, throwable.localizedMessage ?: "error")
|
buildErrorResult(params, "${throwable::class.java.name}: ${throwable.localizedMessage ?: "N/A error message"}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,10 +91,10 @@ internal abstract class SessionSafeCoroutineWorker<PARAM : SessionWorkerParams>(
|
|||||||
* This is called when the input parameters are correct, but contain an error from the previous worker.
|
* This is called when the input parameters are correct, but contain an error from the previous worker.
|
||||||
*/
|
*/
|
||||||
@CallSuper
|
@CallSuper
|
||||||
open fun doOnError(params: PARAM): Result {
|
open fun doOnError(params: PARAM, failureMessage: String): Result {
|
||||||
// Forward the error
|
// Forward the error
|
||||||
return Result.success(inputData)
|
return Result.success(inputData)
|
||||||
.also { Timber.e("Work cancelled due to input error from parent") }
|
.also { Timber.e("Work cancelled due to input error from parent: $failureMessage") }
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
Loading…
Reference in New Issue
Block a user