Show fatal error overlay on startup
This commit is contained in:
parent
fd5748f8df
commit
91f2137cc6
31
src/main.jsx
31
src/main.jsx
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue