From 359d3c5015e7ebbafcb4ea8e5989d118e7ca745d Mon Sep 17 00:00:00 2001 From: monsieurtanuki Date: Sat, 14 Dec 2024 15:33:54 +0100 Subject: [PATCH] fix: 6021 - resilience for svg and 'Connection reset by peer' --- .../category_cards/svg_safe_network.dart | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/smooth_app/lib/cards/category_cards/svg_safe_network.dart b/packages/smooth_app/lib/cards/category_cards/svg_safe_network.dart index c399c17129c0..930ff720b402 100644 --- a/packages/smooth_app/lib/cards/category_cards/svg_safe_network.dart +++ b/packages/smooth_app/lib/cards/category_cards/svg_safe_network.dart @@ -136,16 +136,25 @@ class _SvgSafeNetworkState extends State { } } 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 warningLabels = [ + '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 {