mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-14 04:17:21 +01:00
chore (error): refactoring error controller
This commit is contained in:
parent
3d5560d5f8
commit
792ef4ddfb
5 changed files with 10 additions and 7 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)),
|
||||
));
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue