Replaced three unsafe .first accesses on fetch.messages in email_repository_impl.dart with .firstOrNull + an early throw StateError(...) that names the UID. This turns the cryptic StateError: No element (triggered when an IMAP server returns an empty list due to a network hiccup or an already-expunged UID) into a descriptive error.
Also added snapshot.hasError handling in the FutureBuilder in thread_detail_screen.dart so users see an inline error message instead of an infinite spinner when getEmailBody throws.
Locations fixed
File
Line
Change
email_repository_impl.dart
~240
getEmailBody IMAP path
email_repository_impl.dart
~2816
downloadAttachment IMAP path
email_repository_impl.dart
~2888
fetchRawRfc822 IMAP path
thread_detail_screen.dart
FutureBuilder
added hasError branch
Verification
task analyze — no issues
task test — 491/491 tests passed
Closes #339
## What changed
Replaced three unsafe `.first` accesses on `fetch.messages` in `email_repository_impl.dart` with `.firstOrNull` + an early `throw StateError(...)` that names the UID. This turns the cryptic `StateError: No element` (triggered when an IMAP server returns an empty list due to a network hiccup or an already-expunged UID) into a descriptive error.
Also added `snapshot.hasError` handling in the `FutureBuilder` in `thread_detail_screen.dart` so users see an inline error message instead of an infinite spinner when `getEmailBody` throws.
## Locations fixed
| File | Line | Change |
|------|------|--------|
| `email_repository_impl.dart` | ~240 | `getEmailBody` IMAP path |
| `email_repository_impl.dart` | ~2816 | `downloadAttachment` IMAP path |
| `email_repository_impl.dart` | ~2888 | `fetchRawRfc822` IMAP path |
| `thread_detail_screen.dart` | FutureBuilder | added `hasError` branch |
## Verification
- `task analyze` — no issues
- `task test` — 491/491 tests passed
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #339
What changed
Replaced three unsafe
.firstaccesses onfetch.messagesinemail_repository_impl.dartwith.firstOrNull+ an earlythrow StateError(...)that names the UID. This turns the crypticStateError: No element(triggered when an IMAP server returns an empty list due to a network hiccup or an already-expunged UID) into a descriptive error.Also added
snapshot.hasErrorhandling in theFutureBuilderinthread_detail_screen.dartso users see an inline error message instead of an infinite spinner whengetEmailBodythrows.Locations fixed
email_repository_impl.dartgetEmailBodyIMAP pathemail_repository_impl.dartdownloadAttachmentIMAP pathemail_repository_impl.dartfetchRawRfc822IMAP paththread_detail_screen.darthasErrorbranchVerification
task analyze— no issuestask test— 491/491 tests passed