refactor(web/api): errCode + errMessage helpers; 41 sites migrated (W1)
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
} from '$lib/api/playlists';
|
||||
import { qk } from '$lib/api/queries';
|
||||
import { user } from '$lib/auth/store.svelte';
|
||||
import { copyForCode } from '$lib/api/error-copy';
|
||||
import { errCode, errMessage } from '$lib/api/errors';
|
||||
import { playQueue } from '$lib/player/store.svelte';
|
||||
import type { TrackRef } from '$lib/api/types';
|
||||
|
||||
@@ -48,8 +48,7 @@
|
||||
await reorderPlaylist(id, cur);
|
||||
await queryClient.invalidateQueries({ queryKey: qk.playlist(id) });
|
||||
} catch (e: unknown) {
|
||||
const code = (e as { code?: string })?.code ?? 'unknown';
|
||||
alert(copyForCode(code));
|
||||
alert(errMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +58,7 @@
|
||||
await queryClient.invalidateQueries({ queryKey: qk.playlist(id) });
|
||||
await queryClient.invalidateQueries({ queryKey: qk.playlists() });
|
||||
} catch (e: unknown) {
|
||||
const code = (e as { code?: string })?.code ?? 'unknown';
|
||||
alert(copyForCode(code));
|
||||
alert(errMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,8 +118,7 @@
|
||||
await queryClient.invalidateQueries({ queryKey: qk.playlists() });
|
||||
editing = false;
|
||||
} catch (e: unknown) {
|
||||
const code = (e as { code?: string })?.code ?? 'unknown';
|
||||
alert(copyForCode(code));
|
||||
alert(errMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,8 +129,7 @@
|
||||
await queryClient.invalidateQueries({ queryKey: qk.playlists() });
|
||||
goto('/playlists');
|
||||
} catch (e: unknown) {
|
||||
const code = (e as { code?: string })?.code ?? 'unknown';
|
||||
alert(copyForCode(code));
|
||||
alert(errMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +154,7 @@
|
||||
await queryClient.invalidateQueries({ queryKey: qk.playlist(id) });
|
||||
await queryClient.invalidateQueries({ queryKey: qk.playlists() });
|
||||
} catch (e: unknown) {
|
||||
showToast(`Refresh failed: ${(e as { code?: string })?.code ?? 'unknown'}`);
|
||||
showToast(`Refresh failed: ${errCode(e)}`);
|
||||
} finally {
|
||||
refreshingDiscover = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user