@@ -1339,9 +1339,9 @@ class UpdateMachine {
13391339 lastEventId = events.last.id;
13401340 }
13411341 }
1342- } catch (e) {
1342+ } catch (e, stackTrace ) {
13431343 if (_disposed) return ;
1344- await _handlePollError (e);
1344+ await _handlePollError (e, stackTrace );
13451345 assert (_disposed);
13461346 return ;
13471347 }
@@ -1458,7 +1458,7 @@ class UpdateMachine {
14581458 /// See also:
14591459 /// * [_handlePollRequestError] , which handles certain errors
14601460 /// and causes them not to reach this method.
1461- Future <void > _handlePollError (Object error) async {
1461+ Future <void > _handlePollError (Object error, StackTrace stackTrace ) async {
14621462 // An error occurred, other than the transient request errors we retry on.
14631463 // This means either a lost/expired event queue on the server (which is
14641464 // normal after the app is offline for a period like 10 minutes),
@@ -1493,9 +1493,12 @@ class UpdateMachine {
14931493 isUnexpected = true ;
14941494
14951495 default :
1496- assert (debugLog ('BUG: Unexpected error in event polling: $error \n ' // TODO(log)
1497- 'Replacing event queue…' ));
1498- _reportToUserErrorConnectingToServer (error);
1496+ assert (debugLog ('BUG: Unexpected error in event polling: $error ' )); // TODO(log)
1497+ // Print stack trace in its own log entry; log entries are truncated
1498+ // at 1 kiB (at least on Android), and stack can be longer than that.
1499+ assert (debugLog ('Stack trace:\n $stackTrace ' ));
1500+ assert (debugLog ('Replacing event queue…' ));
1501+ _reportToUserErrorConnectingToServer (error, stackTrace);
14991502 // Similar story to the _EventHandlingException case;
15001503 // separate only so that that other case can print more context.
15011504 // The bug here could be in the server if it's an ApiRequestException,
@@ -1530,12 +1533,18 @@ class UpdateMachine {
15301533 }
15311534 }
15321535
1533- void _reportToUserErrorConnectingToServer (Object error) {
1536+ void _reportToUserErrorConnectingToServer (Object error, [ StackTrace ? stackTrace] ) {
15341537 final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
1538+
1539+ final details = StringBuffer ()..write (error.toString ());
1540+ if (stackTrace != null ) {
1541+ details.write ('\n Stack:\n $stackTrace ' );
1542+ }
1543+
15351544 reportErrorToUserBriefly (
15361545 zulipLocalizations.errorConnectingToServerShort,
15371546 details: zulipLocalizations.errorConnectingToServerDetails (
1538- store.realmUrl.toString (), error .toString ()));
1547+ store.realmUrl.toString (), details .toString ()));
15391548 }
15401549
15411550 /// Cleans up resources and tells the instance not to make new API requests.
0 commit comments