[TS] Renamed file extensions to typescript

This commit is contained in:
Dunemask 2024-03-29 16:45:43 -06:00
parent 4d5b347767
commit 4a6f20fa7b
31 changed files with 12 additions and 0 deletions

View file

@ -1,28 +0,0 @@
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);
};