Why this matters
Silent failures hide defects and make debugging and retries harder.
Do not silently catch and return null on errors; log context and either rethrow or return a typed failure/Result.
Silent failures hide defects and make debugging and retries harder.
Side-by-side examples engineers can pattern-match during review.
Future<User?> load() async {
try {
return await api.getUser();
} catch (_) {
return null; // swallowed
}
}Future<User> load() async {
try {
return await api.getUser();
} catch (e, st) {
logger.severe('load user failed', e, st);
rethrow; // or return a Result.failure(e)
}
}catch (_) { return null; }catch (e, st) { logger.severe('fail', e, st); rethrow; }From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.