Skip to content

Commit 06e9b49

Browse files
Fix v10
1 parent 6dbc68c commit 06e9b49

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

index.html

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,40 @@
7575
</head>
7676

7777
<body>
78-
<div id="root"></div>
78+
<div id="root">
79+
<div
80+
style="display: flex; justify-content: center; align-items: center; height: 100vh; color: white; background-color: #0f172a; font-family: sans-serif; flex-direction: column; gap: 20px;">
81+
<h1>Loading...</h1>
82+
<div id="global-error"
83+
style="color: #ef4444; padding: 20px; background: rgba(0,0,0,0.5); border-radius: 8px; max-width: 80%; display: none; text-align: left; white-space: pre-wrap;">
84+
</div>
85+
</div>
86+
</div>
87+
<script>
88+
// Capture phase listener to catch resource loading errors (404s)
89+
window.addEventListener('error', function (e) {
90+
const errorDiv = document.getElementById('global-error');
91+
if (errorDiv) {
92+
errorDiv.style.display = 'block';
93+
const target = e.target;
94+
// Check if it's a resource loading error
95+
if (target && (target.tagName === 'SCRIPT' || target.tagName === 'LINK' || target.tagName === 'IMG')) {
96+
errorDiv.innerHTML += `<br><strong>Resource Error:</strong> Failed to load ${target.src || target.href}`;
97+
} else {
98+
errorDiv.innerHTML += `<br><strong>Runtime Error:</strong> ${e.message}`;
99+
}
100+
}
101+
}, true); // true = capture phase
102+
103+
// Catch unhandled promise rejections
104+
window.addEventListener('unhandledrejection', function (event) {
105+
const errorDiv = document.getElementById('global-error');
106+
if (errorDiv) {
107+
errorDiv.style.display = 'block';
108+
errorDiv.innerHTML += `<br><strong>Unhandled Promise:</strong> ${event.reason}`;
109+
}
110+
});
111+
</script>
79112
<script type="module" src="src/main.jsx"></script>
80113
</body>
81114

0 commit comments

Comments
 (0)