File
Blob: src/client/pages/ErrorPage.tsx
| 1 | import { TriangleAlert } from "lucide-react"; |
| 2 | import { Button } from "@/client/components/ui/button"; |
| 3 | |
| 4 | export type ErrorPageProps = { |
| 5 | message?: string; |
| 6 | stack?: string; |
| 7 | owner?: string; |
| 8 | repo?: string; |
| 9 | refEnc?: string; |
| 10 | path?: string; |
| 11 | }; |
| 12 | |
| 13 | export function ErrorPage({ message, stack, owner, repo, refEnc, path }: ErrorPageProps) { |
| 14 | return ( |
| 15 | <div className="space-y-6"> |
| 16 | <div className="flex flex-col items-center gap-4 py-10 text-center"> |
| 17 | <span className="inline-grid h-14 w-14 place-items-center rounded-full bg-red-50 dark:bg-red-900/20"> |
| 18 | <TriangleAlert className="h-7 w-7 text-red-500 dark:text-red-400" aria-hidden="true" /> |
| 19 | </span> |
| 20 | <div> |
| 21 | <span className="mb-2 block text-xs font-semibold uppercase tracking-wider text-red-500 dark:text-red-400"> |
| 22 | Error |
| 23 | </span> |
| 24 | <h2 className="m-0 font-display text-2xl font-bold tracking-tight"> |
| 25 | Something went wrong |
| 26 | </h2> |
| 27 | {message ? ( |
| 28 | <p className="mt-2 text-sm text-zinc-500 dark:text-zinc-400">{message}</p> |
| 29 | ) : null} |
| 30 | </div> |
| 31 | </div> |
| 32 | {stack ? ( |
| 33 | <details className="rounded-2xl border border-zinc-200 dark:border-zinc-800/60 bg-white dark:bg-zinc-900/50 p-4"> |
| 34 | <summary className="cursor-pointer select-none">Stack trace</summary> |
| 35 | <pre className="mt-3 overflow-auto whitespace-pre-wrap">{stack}</pre> |
| 36 | </details> |
| 37 | ) : null} |
| 38 | <div className="flex flex-wrap gap-3"> |
| 39 | <Button href="/">Home</Button> |
| 40 | {owner && repo ? ( |
| 41 | <Button variant="secondary" href={`/${owner}/${repo}`}> |
| 42 | Repository |
| 43 | </Button> |
| 44 | ) : null} |
| 45 | {owner && repo && refEnc ? ( |
| 46 | <Button |
| 47 | variant="secondary" |
| 48 | href={`/${owner}/${repo}/tree?ref=${refEnc}${path ? `&path=${encodeURIComponent(path)}` : ""}`} |
| 49 | > |
| 50 | Browse |
| 51 | </Button> |
| 52 | ) : null} |
| 53 | </div> |
| 54 | </div> |
| 55 | ); |
| 56 | } |