File size: 9,364 Bytes
fb12607
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
"use client";

import React, { useEffect, useState } from "react";
import Link from "next/link";
import { AlertCircle, RotateCcw, Home, ChevronDown, ChevronUp, Copy, Check } from "lucide-react";

export default function RootError({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  const [showDetails, setShowDetails] = useState(false);
  const [copied, setCopied] = useState(false);

  useEffect(() => {
    // Log error for client observability
    console.error("[RootError caught]:", error);
  }, [error]);

  const copyDiagnostic = () => {
    const text = `Digest: ${error.digest || "none"}\nMessage: ${error.message}\nStack: ${error.stack || "none"}`;
    navigator.clipboard?.writeText(text);
    setCopied(true);
    setTimeout(() => setCopied(false), 2000);
  };

  return (
    <div
      style={{
        minHeight: "100vh",
        display: "flex",
        flexDirection: "column",
        alignItems: "center",
        justifyContent: "center",
        padding: "var(--space-6, 1.5rem)",
        background: `radial-gradient(ellipse 60% 50% at 50% 40%, rgba(239, 68, 68, 0.08) 0%, rgba(10, 9, 13, 1) 100%), var(--bg-primary, #0A090D)`,
        color: "var(--text-primary, #F6F4F8)",
        textAlign: "center",
        position: "relative",
        overflow: "hidden",
      }}
    >
      {/* Background grid */}
      <div
        aria-hidden="true"
        style={{
          position: "absolute",
          inset: 0,
          backgroundImage:
            "linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px)",
          backgroundSize: "48px 48px",
          pointerEvents: "none",
        }}
      />

      <div style={{ position: "relative", zIndex: 1, maxWidth: 520, width: "100%" }}>
        {/* Status Pill */}
        <div
          style={{
            display: "inline-flex",
            alignItems: "center",
            gap: "var(--space-2, 0.5rem)",
            padding: "4px 12px",
            background: "rgba(239, 68, 68, 0.12)",
            border: "1px solid rgba(239, 68, 68, 0.35)",
            borderRadius: "9999px",
            fontSize: "var(--text-xs, 0.75rem)",
            fontWeight: 600,
            letterSpacing: "0.08em",
            color: "var(--color-error, #EF4444)",
            textTransform: "uppercase",
            marginBottom: "var(--space-6, 1.5rem)",
          }}
        >
          <AlertCircle size={13} />
          <span>System Interruption</span>
        </div>

        {/* EasyUI Glyph-displacement 500 */}
        <div
          style={{
            display: "flex",
            alignItems: "center",
            justifyContent: "center",
            gap: "var(--space-2, 0.5rem)",
            fontFamily: "var(--font-display, monospace)",
            fontSize: "clamp(4.5rem, 14vw, 7.5rem)",
            fontWeight: 800,
            lineHeight: 1,
            letterSpacing: "-0.04em",
            userSelect: "none",
            marginBottom: "var(--space-4, 1rem)",
          }}
        >
          <span
            style={{
              color: "var(--text-primary, #F6F4F8)",
              display: "inline-block",
              animation: "easyui-glyph-bounce 4s ease-in-out infinite",
              textShadow: "0 0 30px rgba(255, 255, 255, 0.1)",
            }}
          >
            5
          </span>
          <span
            style={{
              color: "var(--color-error, #EF4444)",
              display: "inline-block",
              animation: "easyui-glyph-bounce 4s ease-in-out 0.25s infinite",
              textShadow: "0 0 40px rgba(239, 68, 68, 0.4)",
            }}
          >
            0
          </span>
          <span
            style={{
              color: "var(--text-primary, #F6F4F8)",
              display: "inline-block",
              animation: "easyui-glyph-bounce 4s ease-in-out 0.5s infinite",
              textShadow: "0 0 30px rgba(255, 255, 255, 0.1)",
            }}
          >
            0
          </span>
        </div>

        {/* Headline */}
        <h1
          style={{
            fontFamily: "var(--font-display, inherit)",
            fontSize: "clamp(1.4rem, 3.5vw, 1.875rem)",
            fontWeight: 700,
            letterSpacing: "-0.02em",
            marginBottom: "var(--space-3, 0.75rem)",
          }}
        >
          Something hit a technical snag
        </h1>

        {/* Description */}
        <p
          style={{
            fontSize: "var(--text-sm, 0.875rem)",
            color: "var(--text-secondary, #A7A3B4)",
            lineHeight: 1.6,
            marginBottom: "var(--space-6, 1.5rem)",
          }}
        >
          Our application encountered an unexpected runtime error. We&apos;ve logged the incident and our
          audio engineers are looking into it.
        </p>

        {/* Action Buttons */}
        <div
          style={{
            display: "flex",
            flexWrap: "wrap",
            gap: "var(--space-3, 0.75rem)",
            justifyContent: "center",
            marginBottom: "var(--space-6, 1.5rem)",
          }}
        >
          <button
            type="button"
            onClick={() => reset()}
            className="btn btn-primary"
            style={{
              display: "inline-flex",
              alignItems: "center",
              gap: "var(--space-2, 0.5rem)",
              padding: "var(--space-3, 0.75rem) var(--space-6, 1.5rem)",
              fontSize: "var(--text-sm, 0.875rem)",
              fontWeight: 600,
            }}
          >
            <RotateCcw size={15} /> Try Again
          </button>

          <Link
            href="/dashboard"
            className="btn btn-secondary"
            style={{
              display: "inline-flex",
              alignItems: "center",
              gap: "var(--space-2, 0.5rem)",
              textDecoration: "none",
              padding: "var(--space-3, 0.75rem) var(--space-6, 1.5rem)",
              fontSize: "var(--text-sm, 0.875rem)",
              fontWeight: 600,
            }}
          >
            <Home size={15} /> Go to Dashboard
          </Link>
        </div>

        {/* Diagnostic Drawer */}
        <div style={{ width: "100%", textAlign: "left" }}>
          <button
            type="button"
            onClick={() => setShowDetails(!showDetails)}
            style={{
              background: "transparent",
              border: "none",
              color: "var(--text-tertiary, #6D697C)",
              fontSize: "var(--text-xs, 0.75rem)",
              cursor: "pointer",
              display: "inline-flex",
              alignItems: "center",
              gap: 4,
              margin: "0 auto",
            }}
          >
            {showDetails ? (
              <>
                Hide error diagnostic <ChevronUp size={12} />
              </>
            ) : (
              <>
                View error diagnostic <ChevronDown size={12} />
              </>
            )}
          </button>

          {showDetails && (
            <div
              style={{
                marginTop: "var(--space-3, 0.75rem)",
                padding: "var(--space-3, 0.75rem)",
                background: "rgba(0, 0, 0, 0.6)",
                border: "1px solid var(--border-color, #272430)",
                borderRadius: "var(--radius-sm, 2px)",
                fontFamily: "var(--font-mono, monospace)",
                fontSize: "11px",
                color: "var(--text-secondary, #A7A3B4)",
                position: "relative",
              }}
            >
              <div
                style={{
                  display: "flex",
                  justifyContent: "space-between",
                  alignItems: "center",
                  borderBottom: "1px solid var(--border-color-subtle, #1C1924)",
                  paddingBottom: 6,
                  marginBottom: 8,
                }}
              >
                <span style={{ color: "var(--color-primary, #FF9F0A)" }}>
                  Digest: {error.digest || "N/A"}
                </span>
                <button
                  type="button"
                  onClick={copyDiagnostic}
                  style={{
                    background: "none",
                    border: "none",
                    color: copied ? "var(--color-success, #10B981)" : "var(--text-tertiary, #6D697C)",
                    fontSize: "10px",
                    cursor: "pointer",
                    display: "flex",
                    alignItems: "center",
                    gap: 3,
                  }}
                >
                  {copied ? (
                    <>
                      <Check size={11} /> Copied
                    </>
                  ) : (
                    <>
                      <Copy size={11} /> Copy
                    </>
                  )}
                </button>
              </div>
              <div style={{ maxHeight: 160, overflowY: "auto", whiteSpace: "pre-wrap", wordBreak: "break-all" }}>
                <p style={{ color: "var(--color-error, #EF4444)", marginBottom: 4 }}>
                  {error.name}: {error.message}
                </p>
                {error.stack}
              </div>
            </div>
          )}
        </div>
      </div>
    </div>
  );
}