chore (error): refactoring error controller

This commit is contained in:
MickaelK 2023-11-30 00:21:20 +11:00
parent 3d5560d5f8
commit 792ef4ddfb
5 changed files with 10 additions and 7 deletions

View file

@ -45,7 +45,7 @@ export default async function(render) {
if (err instanceof AjaxError) {
switch (err.code()) {
case "INTERNAL_SERVER_ERROR":
ctrlError(err)(render);
ctrlError(render)(err);
return rxjs.EMPTY;
case "FORBIDDEN":
return rxjs.of(false);

View file

@ -36,7 +36,7 @@ export default async function(render) {
throw new ApplicationError("INTERNAL_ERROR", "Assumption failed");
}),
rxjs.tap((ctrl) => ctrl(createRender(qs($page, "[data-bind=\"multistep-form\"]")))),
rxjs.catchError((err) => ctrlError(err)(render)),
rxjs.catchError(ctrlError(render)),
));
};

View file

@ -1,5 +1,4 @@
import rxjs, { effect } from "../../lib/rx.js";
import { AjaxError } from "../../lib/error.js";
import ctrlError from "../ctrl_error.js";
import ctrlLogin from "./ctrl_login.js";

View file

@ -8,12 +8,14 @@ import { AjaxError, ApplicationError } from "../lib/error.js";
import "../components/icon.js";
export default function(err) {
return async function(render) {
const css = await CSS(import.meta.url, "ctrl_error.css")
export default function(render) {
return async function(err) {
const [msg, trace] = processError(err);
const $page = createElement(`
<div>
<style>${await CSS(import.meta.url, "ctrl_error.css")}</style>
<style>${css}</style>
<a href="/" class="backnav">
<component-icon name="arrow_left"></component-icon>
home

View file

@ -1,4 +1,6 @@
import ctrlError from "./ctrl_error.js";
import { ApplicationError } from "../lib/error.js";
export default ctrlError(new ApplicationError("Not Found", "404 - Not Found"));
export default function(render) {
ctrlError(render)(new ApplicationError("Not Found", "404 - Not Found"));
}