Files
t3code/apps/web/src/lib/bootError.ts
T

28 lines
924 B
TypeScript

/** Shows startup failures before React can replace the boot splash. */
export function showBootError(error: unknown) {
console.error("T3 Code failed to start.", error);
const bootShell = document.getElementById("boot-shell");
if (!bootShell) return;
const content = document.createElement("div");
content.id = "boot-error";
content.setAttribute("role", "alert");
const message = document.createElement("p");
message.textContent = "T3 Code could not load.";
content.append(message);
if (import.meta.env.DEV && error instanceof Error) {
const detail = document.createElement("p");
detail.textContent = error.message;
content.append(detail);
}
const reload = document.createElement("button");
reload.type = "button";
reload.textContent = "Reload";
reload.addEventListener("click", () => window.location.reload());
content.append(reload);
bootShell.replaceChildren(content);
}