diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/ui/PollSummaryMapper.kt b/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/ui/PollSummaryMapper.kt index 0bd7cd33af..9d4128e0ac 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/ui/PollSummaryMapper.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/ui/PollSummaryMapper.kt @@ -32,21 +32,28 @@ class PollSummaryMapper @Inject constructor( ) { fun map(timelineEvent: TimelineEvent): PollSummary? { - val content = timelineEvent.getVectorLastMessageContent() - val pollResponseData = pollResponseDataFactory.create(timelineEvent) val eventId = timelineEvent.root.eventId.orEmpty() - val creationTimestamp = timelineEvent.root.originServerTs ?: 0 - return if (eventId.isNotEmpty() && creationTimestamp > 0 && content is MessagePollContent) { - convertToPollSummary( - eventId = eventId, - creationTimestamp = creationTimestamp, - messagePollContent = content, - pollResponseData = pollResponseData - ) - } else { - Timber.w("missing mandatory info about poll event with id=$eventId") - null + val result = runCatching { + val content = timelineEvent.getVectorLastMessageContent() + val pollResponseData = pollResponseDataFactory.create(timelineEvent) + val creationTimestamp = timelineEvent.root.originServerTs ?: 0 + return if (eventId.isNotEmpty() && creationTimestamp > 0 && content is MessagePollContent) { + convertToPollSummary( + eventId = eventId, + creationTimestamp = creationTimestamp, + messagePollContent = content, + pollResponseData = pollResponseData + ) + } else { + Timber.w("missing mandatory info about poll event with id=$eventId") + null + } } + + if (result.isFailure) { + Timber.w("failed to map event with id $eventId") + } + return result.getOrNull() } private fun convertToPollSummary(