ursus
06/21/2019, 3:25 PMprivate fun doPostMessage(...) {
var messageId: Long? = null
try {
messageId = messageRepository.insertSendingTextMessage(...)
val apiMessage = apiClient.postMessage(...)
messageRepository.updateSentMessageAndParents(apiMessage)
} catch (ex: Exception) {
if (messageId != null) messageRepository.updateMessageState(messageId, MessageState.ERROR)
throw ex
}
}
kioba
06/21/2019, 3:31 PMmessageRepository.insertSendingTextMessage(...)
fails you still crashing the app. without properly calling the updateMessageState
ursus
06/21/2019, 3:51 PMkioba
06/21/2019, 3:53 PMinsertSendingTextMessage
fails you won’t set the messageId
so updateMessageState
will be called with an uninitialised variableursus
06/21/2019, 3:53 PM