feat: enhance canvas and node components with error handling and retry logic
- Integrated retry logic for AI image generation to handle transient errors and improve user experience. - Updated error categorization to provide more informative feedback based on different failure scenarios. - Enhanced node components to display retry attempts and error messages, improving visibility during image generation failures. - Refactored canvas and node components to include retry count in status updates, ensuring accurate tracking of generation attempts.
This commit is contained in:
43
app/error.tsx
Normal file
43
app/error.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
type AppErrorProps = {
|
||||
error: Error & { digest?: string };
|
||||
unstable_retry: () => void;
|
||||
};
|
||||
|
||||
export default function AppError({ error, unstable_retry }: AppErrorProps) {
|
||||
useEffect(() => {
|
||||
const safeError = {
|
||||
name: error.name,
|
||||
message:
|
||||
process.env.NODE_ENV === "development"
|
||||
? error.message
|
||||
: "Unexpected application error",
|
||||
digest: error.digest,
|
||||
};
|
||||
|
||||
console.error("[app/error]", safeError);
|
||||
}, [error]);
|
||||
|
||||
return (
|
||||
<main className="flex min-h-screen items-center justify-center bg-background px-4">
|
||||
<div className="w-full max-w-md space-y-4 rounded-xl border bg-card p-6 shadow-sm">
|
||||
<div className="space-y-1 text-center">
|
||||
<h1 className="text-xl font-semibold">Etwas ist schiefgelaufen</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Wir konnten diesen Bereich nicht laden. Du kannst es direkt erneut
|
||||
versuchen.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Button className="w-full" onClick={() => unstable_retry()}>
|
||||
Erneut versuchen
|
||||
</Button>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user