Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | 'use client' import { useEffect } from 'react' import { css } from '../../styled-system/css' interface RouteErrorFallbackProps { error: Error & { digest?: string } reset: () => void /** Label for the error boundary, used in console logging */ label: string /** Text for the secondary "go back" button */ backLabel?: string /** URL for the secondary "go back" button */ backHref?: string } /** * Shared error fallback UI for Next.js route error.tsx files. * Renders inline within the existing layout (nav stays visible). */ export function RouteErrorFallback({ error, reset, label, backLabel = 'Return Home', backHref = '/', }: RouteErrorFallbackProps) { useEffect(() => { console.error(`[${label}]`, error) }, [error, label]) return ( <div data-component="route-error-fallback" data-error-boundary={label} className={css({ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', minHeight: '60vh', padding: '32px', textAlign: 'center', })} > <div className={css({ fontSize: '48px', marginBottom: '16px' })}>Something broke</div> <p className={css({ fontSize: '16px', color: 'gray.600', marginBottom: '24px', maxWidth: '500px', })} > This section encountered an error. The rest of the app should still work. </p> <div className={css({ display: 'flex', gap: '12px', flexWrap: 'wrap', justifyContent: 'center', })} > <button onClick={reset} data-action="retry-section" className={css({ padding: '10px 24px', backgroundColor: 'blue.600', color: 'white', border: 'none', borderRadius: '8px', fontSize: '14px', fontWeight: 'bold', cursor: 'pointer', transition: 'background-color 0.2s', _hover: { backgroundColor: 'blue.700' }, })} > Try Again </button> <a href={backHref} data-action="error-go-back" className={css({ padding: '10px 24px', backgroundColor: 'gray.200', color: 'gray.800', border: 'none', borderRadius: '8px', fontSize: '14px', fontWeight: 'bold', cursor: 'pointer', textDecoration: 'none', transition: 'background-color 0.2s', _hover: { backgroundColor: 'gray.300' }, })} > {backLabel} </a> </div> <details className={css({ marginTop: '32px', maxWidth: '500px', width: '100%', })} > <summary className={css({ cursor: 'pointer', fontSize: '12px', color: 'gray.500', _hover: { color: 'gray.700' }, })} > Technical details </summary> <div className={css({ marginTop: '12px', padding: '12px', backgroundColor: 'gray.100', borderRadius: '8px', textAlign: 'left', })} > <div className={css({ fontSize: '13px', fontWeight: 'bold', marginBottom: '6px', })} > {error.message} </div> {error.digest && ( <div className={css({ fontSize: '11px', color: 'gray.500', marginBottom: '6px', })} > Digest: {error.digest} </div> )} {error.stack && ( <pre className={css({ fontSize: '11px', fontFamily: 'monospace', color: 'gray.600', overflow: 'auto', maxHeight: '180px', whiteSpace: 'pre-wrap', wordBreak: 'break-word', })} > {error.stack} </pre> )} </div> </details> </div> ) } |