@@ -1008,10 +1008,10 @@ class UpdateMachine {
1008
1008
1009
1009
/// This only reports transient errors after reaching
1010
1010
/// a pre-defined threshold of retries.
1011
- void maybeReportTransientError ( String ? message, { String ? details} ) {
1011
+ void maybeReportToUserTransientError ( Object error ) {
1012
1012
accumulatedTransientFailureCount++ ;
1013
1013
if (accumulatedTransientFailureCount > transientFailureCountNotifyThreshold) {
1014
- reportErrorToUserBriefly (message, details : details );
1014
+ _reportToUserErrorConnectingToServer (error );
1015
1015
}
1016
1016
}
1017
1017
@@ -1034,8 +1034,6 @@ class UpdateMachine {
1034
1034
if (_disposed) return ;
1035
1035
1036
1036
store.isLoading = true ;
1037
- final localizations = GlobalLocalizations .zulipLocalizations;
1038
- final serverUrl = store.realmUrl.toString ();
1039
1037
switch (e) {
1040
1038
case ZulipApiException (code: 'BAD_EVENT_QUEUE_ID' ):
1041
1039
assert (debugLog ('Lost event queue for $store . Replacing…' ));
@@ -1047,10 +1045,7 @@ class UpdateMachine {
1047
1045
case Server5xxException ():
1048
1046
assert (debugLog ('Transient error polling event queue for $store : $e \n '
1049
1047
'Backing off, then will retry…' ));
1050
- maybeReportTransientError (
1051
- localizations.errorConnectingToServerShort,
1052
- details: localizations.errorConnectingToServerDetails (
1053
- serverUrl, e.toString ()));
1048
+ maybeReportToUserTransientError (e);
1054
1049
await (backoffMachine ?? = BackoffMachine ()).wait ();
1055
1050
if (_disposed) return ;
1056
1051
assert (debugLog ('… Backoff wait complete, retrying poll.' ));
@@ -1062,10 +1057,7 @@ class UpdateMachine {
1062
1057
if (e.cause is ! SocketException ) {
1063
1058
// Heuristic check to only report interesting errors to the user.
1064
1059
// A [SocketException] is common when the app returns from sleep.
1065
- maybeReportTransientError (
1066
- localizations.errorConnectingToServerShort,
1067
- details: localizations.errorConnectingToServerDetails (
1068
- serverUrl, e.toString ()));
1060
+ maybeReportToUserTransientError (e);
1069
1061
}
1070
1062
await (backoffMachine ?? = BackoffMachine ()).wait ();
1071
1063
if (_disposed) return ;
@@ -1076,10 +1068,7 @@ class UpdateMachine {
1076
1068
assert (debugLog ('Error polling event queue for $store : $e \n '
1077
1069
'Backing off and retrying even though may be hopeless…' ));
1078
1070
// TODO(#186): Handle unrecoverable failures
1079
- reportErrorToUserBriefly (
1080
- localizations.errorConnectingToServerShort,
1081
- details: localizations.errorConnectingToServerDetails (
1082
- serverUrl, e.toString ()));
1071
+ _reportToUserErrorConnectingToServer (e);
1083
1072
await (backoffMachine ?? = BackoffMachine ()).wait ();
1084
1073
if (_disposed) return ;
1085
1074
assert (debugLog ('… Backoff wait complete, retrying poll.' ));
@@ -1119,6 +1108,14 @@ class UpdateMachine {
1119
1108
}
1120
1109
}
1121
1110
1111
+ void _reportToUserErrorConnectingToServer (Object error) {
1112
+ final localizations = GlobalLocalizations .zulipLocalizations;
1113
+ reportErrorToUserBriefly (
1114
+ localizations.errorConnectingToServerShort,
1115
+ details: localizations.errorConnectingToServerDetails (
1116
+ store.realmUrl.toString (), error.toString ()));
1117
+ }
1118
+
1122
1119
/// Send this client's notification token to the server, now and if it changes.
1123
1120
///
1124
1121
/// TODO The returned future isn't especially meaningful (it may or may not
0 commit comments