1- // ignore_for_file: depend_on_referenced_packages, lines_longer_than_80_chars
1+ //
2+ // ignore_for_file: depend_on_referenced_packages, lines_longer_than_80_chars, cascade_invocations, avoid_catches_without_on_clauses
23
34import 'dart:async' ;
45
@@ -298,8 +299,7 @@ class HtPreferencesRepository {
298299 try {
299300 return await _preferencesClient.getHeadlineReadingHistory ();
300301 } on PreferenceNotFoundException {
301- // If not found by client, return empty list as per repository logic
302- return [];
302+ rethrow ; // Propagate specific exceptions like other getters
303303 } on PreferenceUpdateException {
304304 rethrow ;
305305 } catch (e, stackTrace) {
@@ -343,9 +343,7 @@ class HtPreferencesRepository {
343343 // Identify headlines to remove if limit is exceeded
344344 final headlinesToRemove = < Headline > [];
345345 if (updatedHistoryList.length > maxHistorySize) {
346- headlinesToRemove.addAll (
347- updatedHistoryList.sublist (maxHistorySize),
348- );
346+ headlinesToRemove.addAll (updatedHistoryList.sublist (maxHistorySize));
349347 }
350348
351349 try {
@@ -355,12 +353,15 @@ class HtPreferencesRepository {
355353 // Remove oldest headlines via the client if necessary
356354 for (final oldHeadline in headlinesToRemove) {
357355 // Ignore errors during removal of old items, as adding the new one
358- // is the primary goal. Log potentially?
356+ // is the primary goal.
359357 try {
360358 await _preferencesClient.removeHeadlineToHistory (oldHeadline.id);
361359 } catch (_) {
362- // Log removal error? For now, we suppress it.
363- // print('Warning: Failed to remove old history item ${oldHeadline.id}');
360+ // Intentionally suppress errors during the removal of *old* history
361+ // items. The primary goal is to add the *new* headline successfully.
362+ // Failing to prune an old item is less critical than failing the
363+ // entire add operation. Consider logging this error in a real app.
364+ // print('Warning: Failed to remove old history item ${oldHeadline.id}: $_');
364365 }
365366 }
366367 } on PreferenceUpdateException {
0 commit comments