Skip to content

Commit 4d751ff

Browse files
committed
TF-4081 Fix return type mismatch in Future.catchError handler
1 parent 45b5530 commit 4d751ff

File tree

55 files changed

+730
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+730
-201
lines changed

lib/features/caching/clients/hive_cache_version_client.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ class HiveCacheVersionClient extends CacheVersionClient {
1717
return Future.sync(() {
1818
final latestVersion = _sharedPreferences.getInt(versionKey);
1919
return latestVersion;
20-
}).catchError(_exceptionThrower.throwException);
20+
}).catchError((error, stackTrace) async {
21+
await _exceptionThrower.throwException(error, stackTrace);
22+
throw error;
23+
});
2124
}
2225

2326
@override
2427
Future<bool> storeVersion(int newVersion) {
2528
return Future.sync(() async {
2629
return await _sharedPreferences.setInt(versionKey, newVersion);
27-
}).catchError(_exceptionThrower.throwException);
30+
}).catchError((error, stackTrace) async {
31+
await _exceptionThrower.throwException(error, stackTrace);
32+
throw error;
33+
});
2834
}
2935
}

lib/features/cleanup/data/datasource_impl/cleanup_datasource_impl.dart

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,39 @@ class CleanupDataSourceImpl extends CleanupDataSource {
3030
Future<void> cleanEmailCache(EmailCleanupRule cleanupRule) {
3131
return Future.sync(() async {
3232
return await emailCacheManager.clean(cleanupRule);
33-
}).catchError(_exceptionThrower.throwException);
33+
}).catchError((error, stackTrace) async {
34+
await _exceptionThrower.throwException(error, stackTrace);
35+
throw error;
36+
});
3437
}
3538

3639
@override
3740
Future<void> cleanRecentSearchCache(RecentSearchCleanupRule cleanupRule) {
3841
return Future.sync(() async {
3942
return await recentSearchCacheManager.clean(cleanupRule);
40-
}).catchError(_exceptionThrower.throwException);
43+
}).catchError((error, stackTrace) async {
44+
await _exceptionThrower.throwException(error, stackTrace);
45+
throw error;
46+
});
4147
}
4248

4349
@override
4450
Future<void> cleanRecentLoginUrlCache(RecentLoginUrlCleanupRule cleanupRule) {
4551
return Future.sync(() async {
4652
return await recentLoginUrlCacheManager.clean(cleanupRule);
47-
}).catchError(_exceptionThrower.throwException);
53+
}).catchError((error, stackTrace) async {
54+
await _exceptionThrower.throwException(error, stackTrace);
55+
throw error;
56+
});
4857
}
4958

5059
@override
5160
Future<void> cleanRecentLoginUsernameCache(RecentLoginUsernameCleanupRule cleanupRule) {
5261
return Future.sync(() async {
5362
return await recentLoginUsernameCacheManager.clean(cleanupRule);
54-
}).catchError(_exceptionThrower.throwException);
63+
}).catchError((error, stackTrace) async {
64+
await _exceptionThrower.throwException(error, stackTrace);
65+
throw error;
66+
});
5567
}
5668
}

lib/features/composer/data/datasource_impl/composer_datasource_impl.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class ComposerDataSourceImpl extends ComposerDataSource {
3131
filePath: fileInfo.filePath,
3232
maxWidth: maxWidth,
3333
compress: compress);
34-
}).catchError(_exceptionThrower.throwException);
34+
}).catchError((error, stackTrace) async {
35+
await _exceptionThrower.throwException(error, stackTrace);
36+
throw error;
37+
});
3538
}
3639
}

lib/features/composer/data/datasource_impl/contact_datasource_impl.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ class ContactDataSourceImpl extends ContactDataSource {
2525
return <DeviceContact>[];
2626
}
2727
}
28-
}).catchError(_exceptionThrower.throwException);
28+
}).catchError((error, stackTrace) async {
29+
await _exceptionThrower.throwException(error, stackTrace);
30+
throw error;
31+
});
2932
}
3033

3134
List<DeviceContact> _toDeviceContact(contact_service.Contact contact) {

lib/features/contact/data/datasource_impl/tmail_contact_datasource_impl.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class TMailContactDataSourceImpl extends AutoCompleteDataSource {
1818
return Future.sync(() async {
1919
final listContacts = await _contactAPI.getAutoComplete(autoCompletePattern);
2020
return listContacts.map((contact) => contact.toEmailAddress()).toList();
21-
}).catchError(_exceptionThrower.throwException);
21+
}).catchError((error, stackTrace) async {
22+
await _exceptionThrower.throwException(error, stackTrace);
23+
throw error;
24+
});
2225
}
2326
}

lib/features/email/data/datasource_impl/calendar_event_datasource_impl.dart

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ class CalendarEventDataSourceImpl extends CalendarEventDataSource {
2020
Future<List<BlobCalendarEvent>> parse(AccountId accountId, Set<Id> blobIds) {
2121
return Future.sync(() async {
2222
return await _calendarEventAPI.parse(accountId, blobIds);
23-
}).catchError(_exceptionThrower.throwException);
23+
}).catchError((error, stackTrace) async {
24+
await _exceptionThrower.throwException(error, stackTrace);
25+
throw error;
26+
});
2427
}
2528

2629
@override
@@ -30,7 +33,10 @@ class CalendarEventDataSourceImpl extends CalendarEventDataSource {
3033
String? language) {
3134
return Future.sync(() async {
3235
return await _calendarEventAPI.acceptEventInvitation(accountId, blobIds, language);
33-
}).catchError(_exceptionThrower.throwException);
36+
}).catchError((error, stackTrace) async {
37+
await _exceptionThrower.throwException(error, stackTrace);
38+
throw error;
39+
});
3440
}
3541

3642
@override
@@ -40,7 +46,10 @@ class CalendarEventDataSourceImpl extends CalendarEventDataSource {
4046
String? language) {
4147
return Future.sync(() async {
4248
return await _calendarEventAPI.maybeEventInvitation(accountId, blobIds, language);
43-
}).catchError(_exceptionThrower.throwException);
49+
}).catchError((error, stackTrace) async {
50+
await _exceptionThrower.throwException(error, stackTrace);
51+
throw error;
52+
});
4453
}
4554

4655
@override
@@ -50,7 +59,10 @@ class CalendarEventDataSourceImpl extends CalendarEventDataSource {
5059
String? language) {
5160
return Future.sync(() async {
5261
return await _calendarEventAPI.rejectEventInvitation(accountId, blobIds, language);
53-
}).catchError(_exceptionThrower.throwException);
62+
}).catchError((error, stackTrace) async {
63+
await _exceptionThrower.throwException(error, stackTrace);
64+
throw error;
65+
});
5466
}
5567

5668
@override
@@ -60,6 +72,9 @@ class CalendarEventDataSourceImpl extends CalendarEventDataSource {
6072
) {
6173
return Future.sync(() async {
6274
return await _calendarEventAPI.acceptCounterEvent(accountId, blobIds);
63-
}).catchError(_exceptionThrower.throwException);
75+
}).catchError((error, stackTrace) async {
76+
await _exceptionThrower.throwException(error, stackTrace);
77+
throw error;
78+
});
6479
}
6580
}

lib/features/email/data/datasource_impl/email_datasource_impl.dart

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ class EmailDataSourceImpl extends EmailDataSource {
6464
accountId,
6565
emailId,
6666
additionalProperties: additionalProperties);
67-
}).catchError(_exceptionThrower.throwException);
67+
}).catchError((error, stackTrace) async {
68+
await _exceptionThrower.throwException(error, stackTrace);
69+
throw error;
70+
});
6871
}
6972

7073
@override
@@ -102,7 +105,10 @@ class EmailDataSourceImpl extends EmailDataSource {
102105
) {
103106
return Future.sync(() async {
104107
return await emailAPI.markAsRead(session, accountId, emailIds, readActions);
105-
}).catchError(_exceptionThrower.throwException);
108+
}).catchError((error, stackTrace) async {
109+
await _exceptionThrower.throwException(error, stackTrace);
110+
throw error;
111+
});
106112
}
107113

108114
@override
@@ -115,7 +121,10 @@ class EmailDataSourceImpl extends EmailDataSource {
115121
) {
116122
return Future.sync(() async {
117123
return await emailAPI.exportAttachment(attachment, accountId, baseDownloadUrl, accountRequest, cancelToken);
118-
}).catchError(_exceptionThrower.throwException);
124+
}).catchError((error, stackTrace) async {
125+
await _exceptionThrower.throwException(error, stackTrace);
126+
throw error;
127+
});
119128
}
120129

121130
@override
@@ -129,7 +138,10 @@ class EmailDataSourceImpl extends EmailDataSource {
129138
) {
130139
return Future.sync(() async {
131140
return await emailAPI.moveToMailbox(session, accountId, moveRequest);
132-
}).catchError(_exceptionThrower.throwException);
141+
}).catchError((error, stackTrace) async {
142+
await _exceptionThrower.throwException(error, stackTrace);
143+
throw error;
144+
});
133145
}
134146

135147
@override
@@ -149,7 +161,10 @@ class EmailDataSourceImpl extends EmailDataSource {
149161
emailIds,
150162
markStarAction,
151163
);
152-
}).catchError(_exceptionThrower.throwException);
164+
}).catchError((error, stackTrace) async {
165+
await _exceptionThrower.throwException(error, stackTrace);
166+
throw error;
167+
});
153168
}
154169

155170
@override
@@ -166,7 +181,10 @@ class EmailDataSourceImpl extends EmailDataSource {
166181
email,
167182
cancelToken: cancelToken
168183
);
169-
}).catchError(_exceptionThrower.throwException);
184+
}).catchError((error, stackTrace) async {
185+
await _exceptionThrower.throwException(error, stackTrace);
186+
throw error;
187+
});
170188
}
171189

172190
@override
@@ -183,7 +201,10 @@ class EmailDataSourceImpl extends EmailDataSource {
183201
emailId,
184202
cancelToken: cancelToken
185203
);
186-
}).catchError(_exceptionThrower.throwException);
204+
}).catchError((error, stackTrace) async {
205+
await _exceptionThrower.throwException(error, stackTrace);
206+
throw error;
207+
});
187208
}
188209

189210
@override
@@ -202,7 +223,10 @@ class EmailDataSourceImpl extends EmailDataSource {
202223
oldEmailId,
203224
cancelToken: cancelToken
204225
);
205-
}).catchError(_exceptionThrower.throwException);
226+
}).catchError((error, stackTrace) async {
227+
await _exceptionThrower.throwException(error, stackTrace);
228+
throw error;
229+
});
206230
}
207231

208232
@override
@@ -223,7 +247,10 @@ class EmailDataSourceImpl extends EmailDataSource {
223247
createNewMailboxRequest: createNewMailboxRequest,
224248
cancelToken: cancelToken
225249
);
226-
}).catchError(_exceptionThrower.throwException);
250+
}).catchError((error, stackTrace) async {
251+
await _exceptionThrower.throwException(error, stackTrace);
252+
throw error;
253+
});
227254
}
228255

229256
@override
@@ -242,7 +269,10 @@ class EmailDataSourceImpl extends EmailDataSource {
242269
oldEmailId,
243270
cancelToken: cancelToken
244271
);
245-
}).catchError(_exceptionThrower.throwException);
272+
}).catchError((error, stackTrace) async {
273+
await _exceptionThrower.throwException(error, stackTrace);
274+
throw error;
275+
});
246276
}
247277

248278
@override
@@ -260,7 +290,10 @@ class EmailDataSourceImpl extends EmailDataSource {
260290
accountId,
261291
emailIds,
262292
);
263-
}).catchError(_exceptionThrower.throwException);
293+
}).catchError((error, stackTrace) async {
294+
await _exceptionThrower.throwException(error, stackTrace);
295+
throw error;
296+
});
264297
}
265298

266299
@override
@@ -277,7 +310,10 @@ class EmailDataSourceImpl extends EmailDataSource {
277310
emailId,
278311
cancelToken: cancelToken
279312
);
280-
}).catchError(_exceptionThrower.throwException);
313+
}).catchError((error, stackTrace) async {
314+
await _exceptionThrower.throwException(error, stackTrace);
315+
throw error;
316+
});
281317
}
282318

283319
@override
@@ -289,7 +325,10 @@ class EmailDataSourceImpl extends EmailDataSource {
289325
Future<Email> getDetailedEmailById(Session session, AccountId accountId, EmailId emailId) {
290326
return Future.sync(() async {
291327
return await emailAPI.getDetailedEmailById(session, accountId, emailId);
292-
}).catchError(_exceptionThrower.throwException);
328+
}).catchError((error, stackTrace) async {
329+
await _exceptionThrower.throwException(error, stackTrace);
330+
throw error;
331+
});
293332
}
294333

295334
@override
@@ -356,21 +395,30 @@ class EmailDataSourceImpl extends EmailDataSource {
356395
Future<void> unsubscribeMail(Session session, AccountId accountId, EmailId emailId) {
357396
return Future.sync(() async {
358397
return await emailAPI.unsubscribeMail(session, accountId, emailId);
359-
}).catchError(_exceptionThrower.throwException);
398+
}).catchError((error, stackTrace) async {
399+
await _exceptionThrower.throwException(error, stackTrace);
400+
throw error;
401+
});
360402
}
361403

362404
@override
363405
Future<EmailRecoveryAction> restoreDeletedMessage(RestoredDeletedMessageRequest restoredDeletedMessageRequest) {
364406
return Future.sync(() async {
365407
return await emailAPI.restoreDeletedMessage(restoredDeletedMessageRequest);
366-
}).catchError(_exceptionThrower.throwException);
408+
}).catchError((error, stackTrace) async {
409+
await _exceptionThrower.throwException(error, stackTrace);
410+
throw error;
411+
});
367412
}
368413

369414
@override
370415
Future<EmailRecoveryAction> getRestoredDeletedMessage(EmailRecoveryActionId emailRecoveryActionId) {
371416
return Future.sync(() async {
372417
return await emailAPI.getRestoredDeletedMessage(emailRecoveryActionId);
373-
}).catchError(_exceptionThrower.throwException);
418+
}).catchError((error, stackTrace) async {
419+
await _exceptionThrower.throwException(error, stackTrace);
420+
throw error;
421+
});
374422
}
375423

376424
@override
@@ -387,7 +435,10 @@ class EmailDataSourceImpl extends EmailDataSource {
387435
Future<List<Email>> parseEmailByBlobIds(AccountId accountId, Set<Id> blobIds) {
388436
return Future.sync(() async {
389437
return await emailAPI.parseEmailByBlobIds(accountId, blobIds);
390-
}).catchError(_exceptionThrower.throwException);
438+
}).catchError((error, stackTrace) async {
439+
await _exceptionThrower.throwException(error, stackTrace);
440+
throw error;
441+
});
391442
}
392443

393444
@override
@@ -477,7 +528,10 @@ class EmailDataSourceImpl extends EmailDataSource {
477528
);
478529

479530
return previewEmlHtmlDocument;
480-
}).catchError(_exceptionThrower.throwException);
531+
}).catchError((error, stackTrace) async {
532+
await _exceptionThrower.throwException(error, stackTrace);
533+
throw error;
534+
});
481535
}
482536

483537
Future<String> _transformEmailContent(
@@ -528,7 +582,7 @@ class EmailDataSourceImpl extends EmailDataSource {
528582
Future<EMLPreviewer> getPreviewEMLContentInMemory(String keyStored) {
529583
throw UnimplementedError();
530584
}
531-
585+
532586
@override
533587
Future<DownloadedResponse> exportAllAttachments(
534588
AccountId accountId,
@@ -546,7 +600,10 @@ class EmailDataSourceImpl extends EmailDataSource {
546600
accountRequest,
547601
cancelToken: cancelToken,
548602
);
549-
}).catchError(_exceptionThrower.throwException);
603+
}).catchError((error, stackTrace) async {
604+
await _exceptionThrower.throwException(error, stackTrace);
605+
throw error;
606+
});
550607

551608
@override
552609
Future<String> generateEntireMessageAsDocument(ViewEntireMessageRequest entireMessageRequest) {

0 commit comments

Comments
 (0)