fix: log errors in silent catch (_) blocks instead of swallowing them
JMAP push stream failures and UI-layer search/discovery errors now emit a log line via the project logger so they are visible during debugging. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
e7d172eba5
commit
281acdf665
@@ -6,6 +6,13 @@ Tasks get moved from NEXT.md to DONE.md
|
||||
|
||||
## Tasks
|
||||
|
||||
## Replace silent catch (_) with logged errors
|
||||
|
||||
5 `catch (_)` blocks in JMAP push stream setup and 2 in UI screens now use
|
||||
`catch (e)` with `log(...)` via the project's `logger.dart` wrapper.
|
||||
The two intentionally silent catches (malformed SSE JSON, Sent folder already
|
||||
exists) were left as-is since they already had explanatory comments.
|
||||
|
||||
## Safety hardening before real account use
|
||||
|
||||
### 1. Fix non-PEEK body fetch (silently sets \Seen)
|
||||
|
||||
@@ -17,3 +17,15 @@ Git repo should not contain unknown files.
|
||||
Then commit.
|
||||
|
||||
## Tasks
|
||||
|
||||
## Enable always_use_package_imports lint rule
|
||||
|
||||
Add `always_use_package_imports: true` to `analysis_options.yaml`, then fix all relative imports across `lib/` to use `package:sharedinbox3/...` style.
|
||||
|
||||
## Extract _batchMoveToRole helper in email_list_screen
|
||||
|
||||
`_batchArchive()` and `_batchMarkSpam()` in `lib/ui/screens/email_list_screen.dart` (~lines 249–313) share the same pattern: look up a mailbox role, validate, iterate selected ids, call repo method. Extract a shared `_batchMoveToRole(String role)` helper.
|
||||
|
||||
## Extract _tryConnection logic into shared mixin for account screens
|
||||
|
||||
`add_account_screen.dart` and `edit_account_screen.dart` duplicate the `_tryConnection()` method and the `_tryTesting`/`_tryOk`/`_tryErr` state triplet. Extract into a shared mixin or base widget.
|
||||
|
||||
@@ -920,7 +920,8 @@ class EmailRepositoryImpl implements EmailRepository {
|
||||
username: _effectiveUsername(account),
|
||||
password: password,
|
||||
);
|
||||
} catch (_) {
|
||||
} catch (e) {
|
||||
log('JMAP push: connect failed: $e');
|
||||
await controller.close();
|
||||
return;
|
||||
}
|
||||
@@ -946,7 +947,8 @@ class EmailRepositoryImpl implements EmailRepository {
|
||||
await controller.close();
|
||||
return;
|
||||
}
|
||||
} catch (_) {
|
||||
} catch (e) {
|
||||
log('JMAP push: SSE request failed: $e');
|
||||
await controller.close();
|
||||
return;
|
||||
}
|
||||
@@ -977,7 +979,8 @@ class EmailRepositoryImpl implements EmailRepository {
|
||||
onError: (_) => controller.close(),
|
||||
cancelOnError: true,
|
||||
);
|
||||
} catch (_) {
|
||||
} catch (e) {
|
||||
log('JMAP push: unexpected error: $e');
|
||||
await controller.close();
|
||||
}
|
||||
}());
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../core/models/account.dart';
|
||||
import '../../core/models/discovery_result.dart';
|
||||
import '../../core/utils/logger.dart';
|
||||
import '../../di.dart';
|
||||
|
||||
enum _Step { email, detecting, chooseType, jmapForm, imapForm, connecting }
|
||||
@@ -92,7 +93,8 @@ class _AddAccountScreenState extends ConsumerState<AddAccountScreen> {
|
||||
case UnknownDiscovery():
|
||||
setState(() => _step = _Step.chooseType);
|
||||
}
|
||||
} catch (_) {
|
||||
} catch (e) {
|
||||
log('Account discovery failed: $e');
|
||||
if (mounted) setState(() => _step = _Step.chooseType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../core/models/email.dart';
|
||||
import '../../core/models/mailbox.dart';
|
||||
import '../../core/utils/logger.dart';
|
||||
import '../../di.dart';
|
||||
import '../widgets/folder_drawer.dart';
|
||||
|
||||
@@ -92,7 +93,8 @@ class _SearchScreenState extends ConsumerState<SearchScreen> {
|
||||
_loading = false;
|
||||
});
|
||||
}
|
||||
} catch (_) {
|
||||
} catch (e) {
|
||||
log('Search failed: $e');
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user