diff --git a/web/app/adopt/page.js b/web/app/adopt/page.js index 3f364f94..7ac2a8eb 100644 --- a/web/app/adopt/page.js +++ b/web/app/adopt/page.js @@ -159,11 +159,7 @@ export default function AdoptPage() { {loading &&

Loading pets...

} {error && ( -
-

Failed to load pets

- {error} -

Make sure the backend is running and try again.

-
+

Unable to load pets, please try again later.

)} {!loading && !error && displayedPets.length === 0 && ( diff --git a/web/app/contact/page.js b/web/app/contact/page.js index c6f4686d..eb8274e9 100644 --- a/web/app/contact/page.js +++ b/web/app/contact/page.js @@ -28,11 +28,11 @@ export default function ContactPage() { const params = new URLSearchParams({ page: "0", size: "100", sort: "storeName,asc" }); fetch(`/api/v1/stores?${params}`) .then((res) => { - if (!res.ok) throw new Error(`HTTP ${res.status}`); + if (!res.ok) throw new Error("Unable to load store, please try again later."); return res.json(); }) .then((data) => setLocations(data.content ?? [])) - .catch((err) => setError(err.message)) + .catch(() => setError("Unable to load store, please try again later.")) .finally(() => setLoading(false)); }, []); diff --git a/web/app/products/page.js b/web/app/products/page.js index 19cf8670..c71504bd 100644 --- a/web/app/products/page.js +++ b/web/app/products/page.js @@ -80,10 +80,7 @@ export default function ProductsPage() { {loading &&

Loading products...

} {error && ( -
-

Failed to load products

- {error} -
+

Unable to load products, please try again later.

)} {!loading && !error && products.length === 0 && ( diff --git a/web/context/AuthContext.js b/web/context/AuthContext.js index 41482412..07119815 100644 --- a/web/context/AuthContext.js +++ b/web/context/AuthContext.js @@ -64,10 +64,15 @@ export function AuthProvider({ children }) { body: JSON.stringify({ username, password }), }); - const data = await res.json(); + let data; + try { + data = await res.json(); + } catch { + throw new Error("Unable to log in, please try again later."); + } if (!res.ok) { - throw new Error(data.message || "Login failed"); + throw new Error(data.message || "Unable to log in, please try again later."); } const jwt = data.token; @@ -85,16 +90,22 @@ export function AuthProvider({ children }) { headers: { "Content-Type": "application/json" }, body: JSON.stringify({ username, password, email, firstName, lastName, phone }), }); - const data = await res.json(); + + let data; + try { + data = await res.json(); + } catch { + throw new Error("Unable to register, please try again later."); + } if (!res.ok) { if (data.errors && typeof data.errors === "object") { const fieldErrors = Object.entries(data.errors) .map(([field, msg]) => `${field}: ${msg}`) .join(", "); - throw new Error(fieldErrors || data.message || "Registration failed"); + throw new Error(fieldErrors || data.message || "Unable to register, please try again later."); } - throw new Error(data.message || "Registration failed"); + throw new Error(data.message || "Unable to register, please try again later."); } const jwt = data.token; diff --git a/web/next.config.mjs b/web/next.config.mjs index 2a1407d5..1e03b788 100644 --- a/web/next.config.mjs +++ b/web/next.config.mjs @@ -2,6 +2,7 @@ const nextConfig = { output: 'standalone', reactCompiler: true, + devIndicators: false, }; export default nextConfig;