Merge pull request #1626 from famedly/krille/sync-connection-exception
refactor: Add SyncConnectionException to syncloop
This commit is contained in:
commit
ce1727ec52
|
|
@ -19,7 +19,6 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:core';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
|
||||
|
|
@ -1683,7 +1682,7 @@ class Client extends MatrixApi {
|
|||
Logs().d('Running sync while init isn\'t done yet, dropping request');
|
||||
return;
|
||||
}
|
||||
Object? syncError;
|
||||
SyncConnectionException? syncError;
|
||||
await _checkSyncFilter();
|
||||
timeout ??= const Duration(seconds: 30);
|
||||
final syncRequest = sync(
|
||||
|
|
@ -1692,7 +1691,7 @@ class Client extends MatrixApi {
|
|||
timeout: timeout.inMilliseconds,
|
||||
setPresence: syncPresence,
|
||||
).then((v) => Future<SyncUpdate?>.value(v)).catchError((e) {
|
||||
syncError = e;
|
||||
syncError = SyncConnectionException(e);
|
||||
return null;
|
||||
});
|
||||
_currentSyncId = syncRequest.hashCode;
|
||||
|
|
@ -1753,7 +1752,7 @@ class Client extends MatrixApi {
|
|||
Logs().w('The user has been logged out!');
|
||||
await clear();
|
||||
}
|
||||
} on IOException catch (e, s) {
|
||||
} on SyncConnectionException catch (e, s) {
|
||||
Logs().w('Syncloop failed: Client has not connection to the server');
|
||||
onSyncStatus.add(SyncStatusUpdate(SyncStatus.error,
|
||||
error: SdkError(exception: e, stackTrace: s)));
|
||||
|
|
@ -3122,6 +3121,11 @@ class SdkError {
|
|||
SdkError({this.exception, this.stackTrace});
|
||||
}
|
||||
|
||||
class SyncConnectionException implements Exception {
|
||||
final Object originalException;
|
||||
SyncConnectionException(this.originalException);
|
||||
}
|
||||
|
||||
class SyncStatusUpdate {
|
||||
final SyncStatus status;
|
||||
final SdkError? error;
|
||||
|
|
|
|||
Loading…
Reference in New Issue