From 9a9f055c3882935dc62e174b226e024ae5f7a9ce Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Mon, 30 Mar 2026 20:08:23 -0400 Subject: [PATCH] feat(frontend): add API error state management Add centralized error state system: - New ApiError interface (service, message, statusCode, canRetry) - apiError writable store for current error state - isApiDown writable store for API availability status - setApiError() helper to set error states - clearApiError() helper to reset error states Provides reactive error state across entire application. --- .../GlobalVariablesAndHelperFunctions.svelte | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/frontend/src/helperModules/GlobalVariablesAndHelperFunctions.svelte b/frontend/src/helperModules/GlobalVariablesAndHelperFunctions.svelte index 50bacec..a2b5b8e 100644 --- a/frontend/src/helperModules/GlobalVariablesAndHelperFunctions.svelte +++ b/frontend/src/helperModules/GlobalVariablesAndHelperFunctions.svelte @@ -77,6 +77,33 @@ aniListAnime.subscribe((value) => (currentAniListAnime = value)); aniListSort.subscribe((value) => (sort = value)); + export interface ApiError { + service: string; + message: string; + statusCode?: string; + canRetry: boolean; + } + export const apiError = writable(null); + export const isApiDown = writable(false); + export function setApiError( + service: string, + message: string, + statusCode?: string, + canRetry: boolean = true, + ) { + apiError.set({ + service, + message, + statusCode, + canRetry, + }); + isApiDown.set(true); + } + export function clearApiError() { + apiError.set(null); + isApiDown.set(false); + } + export async function GetAnimeSingleItem( aniId: number, login: boolean,