fixing some crashes with naive try/catch blocks

This commit is contained in:
tibbi 2020-12-07 21:53:15 +01:00
parent 7e63bc8821
commit 948a99a5d5
4 changed files with 21 additions and 4 deletions

View File

@ -145,7 +145,12 @@ class CalDAVHelper(val context: Context) {
private fun fetchCalDAVCalendarEvents(calendarId: Int, eventTypeId: Long, showToasts: Boolean) {
val importIdsMap = HashMap<String, Event>()
val fetchedEventIds = ArrayList<String>()
val existingEvents = context.eventsDB.getEventsFromCalDAVCalendar("$CALDAV-$calendarId")
val existingEvents = try {
context.eventsDB.getEventsFromCalDAVCalendar("$CALDAV-$calendarId")
} catch (e: Exception) {
ArrayList()
}
existingEvents.forEach {
importIdsMap[it.importId] = it
}

View File

@ -16,7 +16,11 @@ class Converters {
value
}
return gson.fromJson(newValue, stringType)
return try {
gson.fromJson(newValue, stringType)
} catch (e: Exception) {
ArrayList()
}
}
@TypeConverter

View File

@ -248,7 +248,11 @@ class EventsHelper(val context: Context) {
callback(ArrayList())
return
} else {
eventsDB.getOneTimeEventsFromToWithTypes(toTS, fromTS, context.config.getDisplayEventTypessAsList()).toMutableList() as ArrayList<Event>
try {
eventsDB.getOneTimeEventsFromToWithTypes(toTS, fromTS, context.config.getDisplayEventTypessAsList()).toMutableList() as ArrayList<Event>
} catch (e: Exception) {
ArrayList()
}
}
} else {
if (eventId == -1L) {

View File

@ -86,7 +86,11 @@ data class Event(
while (newDateTime.dayOfMonth().maximumValue < Formatter.getDateTimeFromTS(original.startTS).dayOfMonth().maximumValue) {
newDateTime = newDateTime.plusMonths(repeatInterval / MONTH)
newDateTime = newDateTime.withDayOfMonth(currStart.dayOfMonth)
newDateTime = try {
newDateTime.withDayOfMonth(currStart.dayOfMonth)
} catch (e: Exception) {
newDateTime
}
}
return newDateTime
}