1+ import { useState } from 'react'
12import { Link , isRouteErrorResponse , useRouteError } from 'react-router-dom'
2- import { AlertTriangle , Home , RefreshCw , FileWarning , ServerCrash } from 'lucide-react'
3+ import {
4+ AlertTriangle ,
5+ Home ,
6+ RefreshCw ,
7+ FileWarning ,
8+ ServerCrash ,
9+ Copy ,
10+ Check
11+ } from 'lucide-react'
312import { Button } from '../ui/button'
413import { Card , CardContent } from '../ui/card'
514import { IconBox } from '../layouts/IconBox'
615
716export default function ErrorPage ( ) {
817 const error = useRouteError ( ) as Error | Response | unknown
18+ const [ copied , setCopied ] = useState ( false )
919 console . error ( error )
1020
1121 // Determine error type and message
@@ -34,6 +44,14 @@ export default function ErrorPage() {
3444 window . location . reload ( )
3545 }
3646
47+ const handleCopyStack = async ( ) => {
48+ if ( error instanceof Error && error . stack ) {
49+ await navigator . clipboard . writeText ( error . stack )
50+ setCopied ( true )
51+ setTimeout ( ( ) => setCopied ( false ) , 2000 )
52+ }
53+ }
54+
3755 return (
3856 < div className = "min-h-screen flex items-center justify-center p-6 bg-background" >
3957 < div className = "w-full max-w-md animate-fade-in-up" >
@@ -67,9 +85,23 @@ export default function ErrorPage() {
6785 < summary className = "text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors" >
6886 Technical details
6987 </ summary >
70- < pre className = "mt-2 p-3 bg-muted/50 rounded-lg text-xs font-mono text-muted-foreground overflow-auto max-h-32" >
71- { error . stack }
72- </ pre >
88+ < div className = "relative mt-2" >
89+ < pre className = "p-3 pr-10 bg-muted/50 rounded-lg text-xs font-mono text-muted-foreground overflow-auto max-h-32" >
90+ { error . stack }
91+ </ pre >
92+ < Button
93+ variant = "ghost"
94+ size = "icon"
95+ className = "absolute top-1.5 right-1.5 h-7 w-7 text-muted-foreground hover:text-foreground"
96+ onClick = { handleCopyStack }
97+ >
98+ { copied ? (
99+ < Check className = "h-3.5 w-3.5 text-emerald-500" />
100+ ) : (
101+ < Copy className = "h-3.5 w-3.5" />
102+ ) }
103+ </ Button >
104+ </ div >
73105 </ details >
74106 ) }
75107
@@ -83,12 +115,11 @@ export default function ErrorPage() {
83115 >
84116 Try Again
85117 </ Button >
86- < Button variant = "gradient" className = "flex-1" asChild >
87- < Link to = "/" >
88- < Home className = "h-4 w-4 mr-2" />
118+ < Link to = "/" className = "flex-1" >
119+ < Button variant = "gradient" className = "w-full" leftIcon = { < Home className = "h-4 w-4" /> } >
89120 Go Home
90- </ Link >
91- </ Button >
121+ </ Button >
122+ </ Link >
92123 </ div >
93124 </ CardContent >
94125 </ Card >
0 commit comments