refactor(web/api): errCode + errMessage helpers; 41 sites migrated (W1)
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
type ScanScheduleMode
|
||||
} from '$lib/api/admin';
|
||||
import { qk } from '$lib/api/queries';
|
||||
import { copyForCode } from '$lib/api/error-copy';
|
||||
import { errCode, errMessage } from '$lib/api/errors';
|
||||
import type {
|
||||
AdminQuarantineRow,
|
||||
LidarrRequest,
|
||||
@@ -132,7 +132,7 @@
|
||||
await approveRequest(r.id);
|
||||
await invalidateRequests();
|
||||
} catch (e) {
|
||||
showToast(copyForCode((e as { code?: string }).code));
|
||||
showToast(errMessage(e));
|
||||
}
|
||||
}
|
||||
async function onReject(r: LidarrRequest) {
|
||||
@@ -140,7 +140,7 @@
|
||||
await rejectRequest(r.id);
|
||||
await invalidateRequests();
|
||||
} catch (e) {
|
||||
showToast(copyForCode((e as { code?: string }).code));
|
||||
showToast(errMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@
|
||||
await resolveQuarantine(row.track_id);
|
||||
await invalidateQuarantine();
|
||||
} catch (e) {
|
||||
showToast(copyForCode((e as { code?: string }).code));
|
||||
showToast(errMessage(e));
|
||||
}
|
||||
}
|
||||
async function onDeleteFile(row: AdminQuarantineRow) {
|
||||
@@ -170,7 +170,7 @@
|
||||
await deleteQuarantineFile(row.track_id);
|
||||
await invalidateQuarantine();
|
||||
} catch (e) {
|
||||
showToast(copyForCode((e as { code?: string }).code));
|
||||
showToast(errMessage(e));
|
||||
}
|
||||
}
|
||||
async function onDeleteLidarr(row: AdminQuarantineRow) {
|
||||
@@ -184,7 +184,7 @@
|
||||
await deleteQuarantineViaLidarr(row.track_id);
|
||||
await invalidateQuarantine();
|
||||
} catch (e) {
|
||||
showToast(copyForCode((e as { code?: string }).code));
|
||||
showToast(errMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@
|
||||
await client.invalidateQueries({ queryKey: qk.scanStatus() });
|
||||
await client.invalidateQueries({ queryKey: qk.coverage() });
|
||||
} catch (e) {
|
||||
const code = (e as { code?: string; status?: number })?.code ?? 'unknown';
|
||||
const code = errCode(e);
|
||||
const status = (e as { status?: number })?.status;
|
||||
if (status === 409) {
|
||||
triggerResult = 'A scan is already running.';
|
||||
@@ -286,7 +286,7 @@
|
||||
await updateScanSchedule(patch);
|
||||
await client.invalidateQueries({ queryKey: qk.scanSchedule() });
|
||||
} catch (e) {
|
||||
showToast(`Schedule save failed: ${(e as { code?: string })?.code ?? 'unknown'}`);
|
||||
showToast(`Schedule save failed: ${errCode(e)}`);
|
||||
} finally {
|
||||
scheduleSaving = false;
|
||||
}
|
||||
@@ -325,7 +325,7 @@
|
||||
await researchMissingArt();
|
||||
showToast('All previously-failed art will be re-attempted on the next scan.');
|
||||
} catch (e) {
|
||||
showToast(`Re-search failed: ${(e as { code?: string })?.code ?? 'unknown'}`);
|
||||
showToast(`Re-search failed: ${errCode(e)}`);
|
||||
} finally {
|
||||
researchSaving = false;
|
||||
}
|
||||
@@ -340,7 +340,7 @@
|
||||
bulkResult = `Queued ${queued} albums for cover refetch.`;
|
||||
await client.invalidateQueries({ queryKey: qk.coverage() });
|
||||
} catch (e) {
|
||||
bulkResult = `Failed: ${(e as { code?: string })?.code ?? 'unknown'}`;
|
||||
bulkResult = `Failed: ${errCode(e)}`;
|
||||
} finally {
|
||||
bulkBusy = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user