Log promise failures instead of ignoring them (#531)

In case the failure does not get handled, it should at least get logged, to prevent silently ignoring it
This commit is contained in:
schroda
2023-12-31 01:42:54 +01:00
committed by GitHub
parent 37d6b84cf4
commit 37ce494fda
10 changed files with 44 additions and 13 deletions

View File

@@ -15,6 +15,7 @@ import { requestManager } from '@/lib/requests/RequestManager.ts';
import { makeToast } from '@/components/util/Toast';
import { UpdaterSubscription } from '@/lib/graphql/generated/graphql.ts';
import { Progress } from '@/components/util/Progress';
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
const calcProgress = (status: UpdaterSubscription['updateStatusChanged'] | undefined) => {
if (!status) {
@@ -64,14 +65,14 @@ export function UpdateChecker({ handleFinishedUpdate }: { handleFinishedUpdate?:
lastRunningState = false;
handleFinishedUpdate?.();
// this re-fetch is necessary since a running update could have been triggered by the server or another client
reFetchLastTimestamp().catch(() => {});
reFetchLastTimestamp().catch(defaultPromiseErrorHandler('UpdateChecker::reFetchLastTimestamp'));
}, [status?.isRunning]);
const onClick = async () => {
try {
lastRunningState = true;
await requestManager.startGlobalUpdate().response;
reFetchLastTimestamp().catch(() => {});
reFetchLastTimestamp().catch(defaultPromiseErrorHandler('UpdateChecker::reFetchLastTimestamp'));
} catch (e) {
lastRunningState = false;
makeToast(t('global.error.label.update_failed'), 'error');