This repository was archived by the owner on Feb 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
fluxc/src/main/java/org/wordpress/android/fluxc/persistence Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import com.yarolegovich.wellsql.SelectQuery
66import com.yarolegovich.wellsql.WellSql
77import org.wordpress.android.fluxc.model.list.ListItemModel
88import org.wordpress.android.fluxc.persistence.WellSqlConfig.Companion.SQLITE_MAX_VARIABLE_NUMBER
9+ import org.wordpress.android.util.AppLog
10+ import org.wordpress.android.util.AppLog.T
911import javax.inject.Inject
1012import javax.inject.Singleton
1113
@@ -24,8 +26,19 @@ class ListItemSqlUtils @Inject constructor() {
2426
2527 /* *
2628 * This function returns a list of [ListItemModel] records for the given [listId].
29+ * It catches exceptions that occur during the database query and handles them.
2730 */
28- fun getListItems (listId : Int ): List <ListItemModel > = getListItemsQuery(listId).asModel
31+ @Suppress(" TooGenericExceptionCaught" )
32+ fun getListItems (listId : Int ): List <ListItemModel > {
33+ return try {
34+ // Attempt to execute the query and map the result to models
35+ getListItemsQuery(listId).asModel
36+ } catch (e: Exception ) {
37+ // Handle exceptions that might occur
38+ AppLog .e(T .DB , " Error fetching items for listId: $listId " , e)
39+ emptyList()
40+ }
41+ }
2942
3043 /* *
3144 * This function returns the number of records a list has for the given [listId].
You can’t perform that action at this time.
0 commit comments