Show fatal error overlay on startup

This commit is contained in:
Your Name 2025-12-30 20:39:26 -05:00
parent fd5748f8df
commit 91f2137cc6
1 changed files with 31 additions and 0 deletions

View File

@ -21,6 +21,37 @@ import { AuthProvider } from "./auth/AuthContext.jsx";
// Import pour PWA install
import { promptInstall } from './pwaInstall';
function installGlobalErrorOverlay() {
if (typeof window === "undefined") return;
const show = (msg) => {
try {
let el = document.getElementById("sw-fatal");
if (!el) {
el = document.createElement("div");
el.id = "sw-fatal";
el.style.position = "fixed";
el.style.inset = "0";
el.style.background = "#0b0f1a";
el.style.color = "#e2e8f0";
el.style.zIndex = "999999";
el.style.padding = "24px";
el.style.fontFamily = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace";
el.style.whiteSpace = "pre-wrap";
document.body.appendChild(el);
}
el.textContent = `SocioWire error:\\n${msg}`;
} catch {}
};
window.addEventListener("error", (e) => {
show(e?.message || String(e));
});
window.addEventListener("unhandledrejection", (e) => {
show(e?.reason?.message || String(e?.reason || e));
});
}
installGlobalErrorOverlay();
ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode>
<AuthProvider>