mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-08-11 23:50:19 -04:00
fix DHTRecordCubit open() retry bug
improve error state reporting for cubits
This commit is contained in:
parent
ab9838f375
commit
83880d79ba
14 changed files with 38 additions and 24 deletions
|
@ -58,6 +58,7 @@ class DHTLogCubit<T> extends Cubit<DHTLogBusyState<T>>
|
|||
}
|
||||
}
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(DHTLogBusyState(AsyncValue.error(e, st)));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ abstract class DHTRecordCubit<T> extends Cubit<AsyncValue<T>> {
|
|||
}
|
||||
}
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(AsyncValue.error(e, st));
|
||||
return;
|
||||
}
|
||||
|
@ -53,8 +54,9 @@ abstract class DHTRecordCubit<T> extends Cubit<AsyncValue<T>> {
|
|||
if (initialState != null) {
|
||||
emit(AsyncValue.data(initialState));
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
emit(AsyncValue.error(e));
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(AsyncValue.error(e, st));
|
||||
}
|
||||
|
||||
_subscription = await record!.listen((record, data, subkeys) async {
|
||||
|
@ -63,8 +65,9 @@ abstract class DHTRecordCubit<T> extends Cubit<AsyncValue<T>> {
|
|||
if (newState != null) {
|
||||
emit(AsyncValue.data(newState));
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
emit(AsyncValue.error(e));
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(AsyncValue.error(e, st));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -402,11 +402,13 @@ class DHTRecordPool with TableDBBackedJson<DHTRecordPoolAllocations> {
|
|||
recordDescriptor =
|
||||
await dhtctx.openDHTRecord(recordKey, writer: writer);
|
||||
break;
|
||||
} on VeilidAPIExceptionTryAgain {
|
||||
throw const DHTExceptionNotAvailable();
|
||||
} on VeilidAPIExceptionKeyNotFound {
|
||||
await asyncSleep();
|
||||
retry--;
|
||||
if (retry == 0) {
|
||||
throw DHTExceptionNotAvailable();
|
||||
throw const DHTExceptionNotAvailable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ class DHTShortArrayCubit<T> extends Cubit<DHTShortArrayBusyState<T>>
|
|||
}
|
||||
}
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(DHTShortArrayBusyState<T>(AsyncValue.error(e, st)));
|
||||
return;
|
||||
}
|
||||
|
@ -96,8 +97,9 @@ class DHTShortArrayCubit<T> extends Cubit<DHTShortArrayBusyState<T>>
|
|||
}
|
||||
emit(AsyncValue.data(newState));
|
||||
setRefreshed();
|
||||
} on Exception catch (e) {
|
||||
emit(AsyncValue.error(e));
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(AsyncValue.error(e, st));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue