From 29d0e673e0d1002cafcafffea2e78e7eb3103f35 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 24 Feb 2021 09:17:04 +0100 Subject: [PATCH] fix: Sync error handling --- lib/src/client.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index 7dfc3014..a4132505 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -974,10 +974,13 @@ class Client extends MatrixApi { since: prevBatch, timeout: prevBatch != null ? 30000 : null, setPresence: syncPresence, - ).catchError((e) => syncError = e); + ).catchError((e) { + syncError = e; + return null; + }); _currentSyncId = syncRequest.hashCode; final syncResp = await syncRequest; - if (syncError != null) throw syncError; + if (syncResp == null) throw syncError ?? 'Unknown sync error'; if (_currentSyncId != syncRequest.hashCode) { Logs() .w('Current sync request ID has changed. Dropping this sync loop!'); @@ -1021,7 +1024,7 @@ class Client extends MatrixApi { clear(); } } on MatrixConnectionException catch (e, s) { - Logs().w('Synchronization connection failed', e); + Logs().w('Synchronization connection failed'); onSyncError.add(SdkError(exception: e, stackTrace: s)); } catch (e, s) { if (!isLogged() || _disposed || _aborted) return;