Nest the try catch blocks

This commit is contained in:
Benoit Marty 2019-10-08 14:00:11 +02:00
parent d4dfb76e80
commit 549f749682

View File

@ -90,11 +90,11 @@ internal class DefaultPushRuleService @Inject constructor(private val getPushRul
} }
override fun updatePushRuleEnableStatus(kind: RuleKind, pushRule: PushRule, enabled: Boolean, callback: MatrixCallback<Unit>): Cancelable { override fun updatePushRuleEnableStatus(kind: RuleKind, pushRule: PushRule, enabled: Boolean, callback: MatrixCallback<Unit>): Cancelable {
// The rules will be updated, and will come back from the next sync response
return updatePushRuleEnableStatusTask return updatePushRuleEnableStatusTask
.configureWith(UpdatePushRuleEnableStatusTask.Params(kind, pushRule, enabled)) { .configureWith(UpdatePushRuleEnableStatusTask.Params(kind, pushRule, enabled)) {
this.callback = callback this.callback = callback
} }
// TODO Fetch the rules
.executeBy(taskExecutor) .executeBy(taskExecutor)
} }
@ -125,61 +125,61 @@ internal class DefaultPushRuleService @Inject constructor(private val getPushRul
fun dispatchBing(event: Event, rule: PushRule) { fun dispatchBing(event: Event, rule: PushRule) {
synchronized(listeners) { synchronized(listeners) {
try { val actionsList = rule.getActions()
val actionsList = rule.getActions() listeners.forEach {
listeners.forEach { try {
it.onMatchRule(event, actionsList) it.onMatchRule(event, actionsList)
} catch (e: Throwable) {
Timber.e(e, "Error while dispatching bing")
} }
} catch (e: Throwable) {
Timber.e(e, "Error while dispatching bing")
} }
} }
} }
fun dispatchRoomJoined(roomId: String) { fun dispatchRoomJoined(roomId: String) {
synchronized(listeners) { synchronized(listeners) {
try { listeners.forEach {
listeners.forEach { try {
it.onRoomJoined(roomId) it.onRoomJoined(roomId)
} catch (e: Throwable) {
Timber.e(e, "Error while dispatching room joined")
} }
} catch (e: Throwable) {
Timber.e(e, "Error while dispatching room joined")
} }
} }
} }
fun dispatchRoomLeft(roomId: String) { fun dispatchRoomLeft(roomId: String) {
synchronized(listeners) { synchronized(listeners) {
try { listeners.forEach {
listeners.forEach { try {
it.onRoomLeft(roomId) it.onRoomLeft(roomId)
} catch (e: Throwable) {
Timber.e(e, "Error while dispatching room left")
} }
} catch (e: Throwable) {
Timber.e(e, "Error while dispatching room left")
} }
} }
} }
fun dispatchRedactedEventId(redactedEventId: String) { fun dispatchRedactedEventId(redactedEventId: String) {
synchronized(listeners) { synchronized(listeners) {
try { listeners.forEach {
listeners.forEach { try {
it.onEventRedacted(redactedEventId) it.onEventRedacted(redactedEventId)
} catch (e: Throwable) {
Timber.e(e, "Error while dispatching redacted event")
} }
} catch (e: Throwable) {
Timber.e(e, "Error while dispatching redacted event")
} }
} }
} }
fun dispatchFinish() { fun dispatchFinish() {
synchronized(listeners) { synchronized(listeners) {
try { listeners.forEach {
listeners.forEach { try {
it.batchFinish() it.batchFinish()
} catch (e: Throwable) {
Timber.e(e, "Error while dispatching finish")
} }
} catch (e: Throwable) {
Timber.e(e, "Error while dispatching finish")
} }
} }
} }