v3: error cards across the app, friendly network errors, code quality pass
This commit is contained in:
10
src/utils/apiError.ts
Normal file
10
src/utils/apiError.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 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.";
|
||||
}
|
||||
Reference in New Issue
Block a user