import { createElement } from "../lib/skeleton/index.js"; import rxjs, { effect, applyMutation } from "../lib/rxjs/index.js"; import { qs } from "../lib/dom/index.js"; import { AjaxError } from "../lib/error/index.js"; import CSSLoader from "../helpers/css.js"; import "../../components/icon.js"; function t(str) { return str; } export default function(render) { return function(err) { let msg = "" let trace = ""; if (err instanceof AjaxError) { msg = err.code(); trace = `type: ${err.type()} message: ${err.message} trace: ${err.stack} code: ${err.code} origErr: ${err} `; } else { msg = err.message; trace = `${err.stack || "N/A"}`; } const showTrace = false; const $page = createElement(`
home

${t("Oops!")}

${t(msg)}

`); render($page); // feature: click on h2 toggles the trace visibility effect(rxjs.merge( rxjs.fromEvent(qs($page, "h2"), "click"), rxjs.fromEvent(qs($page, "h1"), "click"), ).pipe( rxjs.mapTo(["hidden"]), applyMutation(qs($page, "code"), "classList", "toggle"), )); return rxjs.of(err); } } const css = await CSSLoader(import.meta, "ctrl_error.css");