|
1 | 1 | <script lang="ts"> |
2 | | - let { error, title = 'Application Error', showDetails = true }: { |
| 2 | + let { error, title = 'Application Error' }: { |
3 | 3 | error: Error | string; |
4 | 4 | title?: string; |
5 | | - showDetails?: boolean; |
6 | 5 | } = $props(); |
7 | 6 |
|
8 | | - const errorMessage = $derived(error instanceof Error ? error.message : String(error)); |
9 | | - const errorStack = $derived(error instanceof Error ? error.stack : null); |
| 7 | + // Determine if this is a network/connection error for user-friendly messaging |
| 8 | + const isNetworkError = $derived(() => { |
| 9 | + const msg = error instanceof Error ? error.message : String(error); |
| 10 | + return msg.toLowerCase().includes('network') || |
| 11 | + msg.toLowerCase().includes('fetch') || |
| 12 | + msg.toLowerCase().includes('connection'); |
| 13 | + }); |
| 14 | +
|
| 15 | + // User-friendly message - never expose raw error details |
| 16 | + const userMessage = $derived( |
| 17 | + isNetworkError() |
| 18 | + ? 'Unable to connect to the server. Please check your internet connection and try again.' |
| 19 | + : 'Something went wrong. Our team has been notified and is working on it.' |
| 20 | + ); |
10 | 21 |
|
11 | 22 | function reload() { |
12 | 23 | window.location.reload(); |
|
33 | 44 | {title} |
34 | 45 | </h1> |
35 | 46 |
|
36 | | - <!-- Error Message --> |
37 | | - <p class="text-center text-red-600 dark:text-red-400 mb-6"> |
38 | | - {errorMessage} |
| 47 | + <!-- User-friendly Error Message --> |
| 48 | + <p class="text-center text-fg-muted dark:text-dark-fg-muted mb-6"> |
| 49 | + {userMessage} |
39 | 50 | </p> |
40 | 51 |
|
41 | | - <!-- Stack Trace (collapsible) --> |
42 | | - {#if showDetails && errorStack} |
43 | | - <details class="mb-6"> |
44 | | - <summary class="cursor-pointer text-sm text-fg-muted dark:text-dark-fg-muted hover:text-fg-default dark:hover:text-dark-fg-default transition-colors"> |
45 | | - Show technical details |
46 | | - </summary> |
47 | | - <pre class="mt-2 p-3 bg-code-bg rounded-lg text-xs text-gray-300 overflow-x-auto max-h-48 overflow-y-auto font-mono">{errorStack}</pre> |
48 | | - </details> |
49 | | - {/if} |
50 | | - |
51 | 52 | <!-- Actions --> |
52 | 53 | <div class="flex flex-col sm:flex-row gap-3"> |
53 | 54 | <button |
|
66 | 67 |
|
67 | 68 | <!-- Help Text --> |
68 | 69 | <p class="mt-6 text-xs text-center text-fg-muted dark:text-dark-fg-muted"> |
69 | | - If this problem persists, please check the browser console for more details. |
| 70 | + If this problem persists, please contact support. |
70 | 71 | </p> |
71 | 72 | </div> |
72 | 73 | </div> |
0 commit comments