1/** Shows startup failures before React can replace the boot splash. */
2export function showBootError(error: unknown) {
3 console.error("The Knife failed to start.", error);
4 const bootShell = document.getElementById("boot-shell");
5 if (!bootShell) return;
6
7 const content = document.createElement("div");
8 content.id = "boot-error";
9 content.setAttribute("role", "alert");
10
11 const message = document.createElement("p");
12 message.textContent = "The Knife could not load.";
13 content.append(message);
14
15 if (import.meta.env.DEV && error instanceof Error) {
16 const detail = document.createElement("p");
17 detail.textContent = error.message;
18 content.append(detail);
19 }
20
21 const reload = document.createElement("button");
22 reload.type = "button";
23 reload.textContent = "Reload";
24 reload.addEventListener("click", () => window.location.reload());
25 content.append(reload);
26 bootShell.replaceChildren(content);
27}