Skip to content

Commit

Permalink
fix: 6021 - resilience for svg and 'Connection reset by peer'
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurtanuki committed Dec 14, 2024
1 parent 331fb64 commit 359d3c5
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions packages/smooth_app/lib/cards/category_cards/svg_safe_network.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,25 @@ class _SvgSafeNetworkState extends State<SvgSafeNetwork> {
}
}
if (snapshot.error != null) {
if (snapshot.error.toString().contains("Failed host lookup: '")) {
Logs.w(
'Failed host lookup for "$_url"',
ex: snapshot.error,
);
} else if (snapshot.error
.toString()
.contains('Connection timed out')) {
String? findWarningLabel() {
const List<String> warningLabels = <String>[
'Failed host lookup',
'Connection timed out',
'Connection reset by peer',
];
final String error = snapshot.error.toString();
for (final String warningLabel in warningLabels) {
if (error.contains(warningLabel)) {
return warningLabel;
}
}
return null;
}

final String? warningLabel = findWarningLabel();
if (warningLabel != null) {
Logs.w(
'Connection timed out for "$_url"',
'$warningLabel for "$_url"',
ex: snapshot.error,
);
} else {
Expand Down

0 comments on commit 359d3c5

Please sign in to comment.