@@ -1034,6 +1034,8 @@ class UpdateMachine {
1034
1034
if (_disposed) return ;
1035
1035
1036
1036
store.isLoading = true ;
1037
+ bool isUnexpected;
1038
+ bool shouldReportToUser;
1037
1039
switch (e) {
1038
1040
case ZulipApiException (code: 'BAD_EVENT_QUEUE_ID' ):
1039
1041
assert (debugLog ('Lost event queue for $store . Replacing…' ));
@@ -1042,31 +1044,38 @@ class UpdateMachine {
1042
1044
assert (debugLog ('… Event queue replaced.' ));
1043
1045
return ;
1044
1046
1047
+ case NetworkException (cause: SocketException ()):
1048
+ // A [SocketException] is common when the app returns from sleep.
1049
+ isUnexpected = false ;
1050
+ shouldReportToUser = false ;
1051
+
1045
1052
case NetworkException ():
1046
1053
case Server5xxException ():
1047
- assert (debugLog ('Transient error polling event queue for $store : $e \n '
1048
- 'Backing off, then will retry…' ));
1049
- if (e is NetworkException && e.cause is SocketException ) {
1050
- // The error is boring; skip reporting it to the user.
1051
- // A [SocketException] is common when the app returns from sleep.
1052
- } else {
1053
- maybeReportToUserTransientError (e);
1054
- }
1055
- await (backoffMachine ?? = BackoffMachine ()).wait ();
1056
- if (_disposed) return ;
1057
- assert (debugLog ('… Backoff wait complete, retrying poll.' ));
1058
- continue ;
1054
+ isUnexpected = false ;
1055
+ shouldReportToUser = true ;
1059
1056
1060
1057
default :
1061
- assert (debugLog ('Error polling event queue for $store : $e \n '
1062
- 'Backing off and retrying even though may be hopeless…' ));
1063
- // TODO(#186): Handle unrecoverable failures
1064
- _reportToUserErrorConnectingToServer (e);
1065
- await (backoffMachine ?? = BackoffMachine ()).wait ();
1066
- if (_disposed) return ;
1067
- assert (debugLog ('… Backoff wait complete, retrying poll.' ));
1068
- continue ;
1058
+ isUnexpected = true ;
1059
+ shouldReportToUser = true ;
1060
+ }
1061
+
1062
+ if (isUnexpected) {
1063
+ assert (shouldReportToUser);
1064
+ assert (debugLog ('Error polling event queue for $store : $e \n '
1065
+ 'Backing off and retrying even though may be hopeless…' ));
1066
+ // TODO(#186): Handle unrecoverable failures
1067
+ _reportToUserErrorConnectingToServer (e);
1068
+ } else {
1069
+ assert (debugLog ('Transient error polling event queue for $store : $e \n '
1070
+ 'Backing off, then will retry…' ));
1071
+ if (shouldReportToUser) {
1072
+ maybeReportToUserTransientError (e);
1073
+ }
1069
1074
}
1075
+ await (backoffMachine ?? = BackoffMachine ()).wait ();
1076
+ if (_disposed) return ;
1077
+ assert (debugLog ('… Backoff wait complete, retrying poll.' ));
1078
+ continue ;
1070
1079
}
1071
1080
1072
1081
// After one successful request, we reset backoff to its initial state.
0 commit comments