[FEATURE] Basic System with file manager (#4)

Co-authored-by: dunemask <dunemask@gmail.com>
Co-authored-by: Dunemask <dunemask@gmail.com>
Reviewed-on: https://gitea.dunemask.dev/elysium/minecluster/pulls/4
This commit is contained in:
dunemask 2023-12-20 03:20:04 +00:00
parent 8fb5b34c77
commit 4f19cf19d9
62 changed files with 5910 additions and 1190 deletions

View file

@ -0,0 +1,28 @@
import { VERB } from "./logging.js";
export default class ExpressClientError extends Error {
constructor(message, clientOptions = {}) {
var msg;
if (typeof message === "object" && message.m !== undefined) msg = message.m;
else if (typeof message === "object") msg = "Unknown Express Client Error!";
super(msg);
if (typeof message === "object") this.clientOptions = message;
else this.clientOptions = { message: msg, ...clientOptions };
}
sendError(res) {
if (!this.clientOptions.m && this.clientOptions.c)
res.sendStatus(this.clientOptions.c);
else res.status(this.clientOptions.c ?? 500).send(this.toString());
}
toString() {
return this.message;
}
}
export const sendError = (res) => (e) => {
VERB("V", e);
if (e instanceof ExpressClientError) e.sendError(res);
else res.status(500).send(e);
};