Files
gerbeur/src/utils/apiError.ts

11 lines
414 B
TypeScript

/**
* Convert a caught fetch error into a human-readable message.
* TypeError means the request never left the client (no network / CORS / etc.).
*/
export function friendlyFetchError(err: unknown): string {
if (err instanceof TypeError) {
return "Could not connect to the server. Check your connection and try again.";
}
return err instanceof Error ? err.message : "An unexpected error occurred.";
}