refactor(web/api): errCode + errMessage helpers; 41 sites migrated (W1)

This commit is contained in:
2026-05-07 22:17:45 -04:00
parent 965df28127
commit 9c91a342e2
16 changed files with 138 additions and 70 deletions
+6 -8
View File
@@ -9,7 +9,7 @@
deleteQuarantineViaLidarr
} from '$lib/api/admin';
import { qk } from '$lib/api/queries';
import { copyForCode } from '$lib/api/error-copy';
import { errMessage } from '$lib/api/errors';
import { playRadio } from '$lib/player/store.svelte';
import type { AdminQuarantineRow, LidarrQuarantineReason } from '$lib/api/types';
@@ -89,8 +89,7 @@
await resolveQuarantine(r.track_id);
await invalidate();
} catch (e) {
const code = (e as { code?: string }).code ?? 'unknown';
showToast(copyForCode(code));
showToast(errMessage(e));
}
}
@@ -108,8 +107,7 @@
await deleteQuarantineFile(r.track_id);
await invalidate();
} catch (e) {
const code = (e as { code?: string }).code ?? 'unknown';
showToast(copyForCode(code));
showToast(errMessage(e));
}
}
@@ -135,12 +133,12 @@
deleteLidarrError = null;
await invalidate();
} catch (e) {
const code = (e as { code?: string }).code ?? 'unknown';
const msg = errMessage(e);
// Inline error keeps the modal open so the operator sees the failure
// alongside the album they were about to remove.
deleteLidarrError = copyForCode(code);
deleteLidarrError = msg;
// Also surface as toast so it's visible after dismissing the modal.
showToast(copyForCode(code));
showToast(msg);
}
}