Spaces:
Sleeping
Sleeping
Caner Giden commited on
Commit ·
e19010e
1
Parent(s): b4515a8
Improve error handling: Better auth error messages with Settings link
Browse filesFiles changed (2)
41 unmodified lines424344454546474849505152535491 unmodified lines14614714814914315015115215315415515615715815916016116216316416516616716816917017141 unmodified lines // Redirect to project detail page router.push(`/projects/${data.data.id || data.data.id}`); } else { setError(data.error || data.data?.detail || "Failed to create project"); // Check if it's an auth error const errorMsg = data.error || data.data?.detail || "Failed to create project"; if (errorMsg.toLowerCase().includes("authorization") || res.status === 401 || res.status === 403) { setError("Authentication required. Please configure your API key in Settings."); } else { setError(errorMsg); } } } catch (e: any) { setError(e?.message ?? "Failed to create project");91 unmodified lines marginBottom: 20, }} > <div style={{ marginBottom: error.includes("Authentication") ? 8 : 0 }}> {error} {error} </div> {error.includes("Authentication") && ( <Link href="/settings" style={{ display: "inline-block", marginTop: 8, padding: "6px 12px", fontSize: 12, backgroundColor: "#0070f3", color: "white", textDecoration: "none", borderRadius: 4, }} > Go to Settings → </Link> )} </div> )}
40 unmodified lines414243444445464748495051525358 unmodified lines11211311411510911611711811912012112212312412512612712812913013113213313413513613740 unmodified lines const projectsList = Array.isArray(data.data) ? data.data : data.data.items || []; setProjects(projectsList); } else { setError(data.error || "Failed to fetch projects"); // Check if it's an auth error const errorMsg = data.error || data.data?.detail || "Failed to fetch projects"; if (errorMsg.toLowerCase().includes("authorization") || res.status === 401 || res.status === 403) { setError("Authentication required. Please configure your API key in Settings."); } else { setError(errorMsg); } } } catch (e: any) { setError(e?.message ?? "Failed to fetch projects");58 unmodified lines marginBottom: 24, }} > <div style={{ marginBottom: error.includes("Authentication") ? 8 : 0 }}> Error: {error} Error: {error} </div> {error.includes("Authentication") && ( <Link href="/settings" style={{ display: "inline-block", marginTop: 8, padding: "6px 12px", fontSize: 12, backgroundColor: "#0070f3", color: "white", textDecoration: "none", borderRadius: 4, }} > Go to Settings → </Link> )} </div> )}
app/projects/new/page.tsx+27-2
app/projects/page.tsx+27-2