summary refs log tree commit diff
path: root/api/src/middlewares
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-03 04:04:34 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-03 04:04:34 +0200
commite662c983b31b5f437084f1b78b542d67fbda3182 (patch)
tree51bc887fdea0fccb600abab636311adaa1fb86ac /api/src/middlewares
parent:bug: fix #289 (diff)
downloadserver-e662c983b31b5f437084f1b78b542d67fbda3182.tar.xz
:bug: fix message sending
Diffstat (limited to 'api/src/middlewares')
-rw-r--r--api/src/middlewares/ErrorHandler.ts9
1 files changed, 4 insertions, 5 deletions
diff --git a/api/src/middlewares/ErrorHandler.ts b/api/src/middlewares/ErrorHandler.ts
index f061172a..34827cab 100644
--- a/api/src/middlewares/ErrorHandler.ts
+++ b/api/src/middlewares/ErrorHandler.ts
@@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from "express";
 import { HTTPError } from "lambert-server";
 import { EntityNotFoundError } from "typeorm";
 import { FieldError } from "../util/instanceOf";
-import {ApiError} from "../util/ApiError";
+import { ApiError } from "../util/ApiError";
 
 // TODO: update with new body/typorm validation
 export function ErrorHandler(error: Error, req: Request, res: Response, next: NextFunction) {
@@ -19,16 +19,15 @@ export function ErrorHandler(error: Error, req: Request, res: Response, next: Ne
 			code = error.code;
 			message = error.message;
 			httpcode = error.httpStatus;
-		}
-		else if (error instanceof EntityNotFoundError) {
-			message = `${(error as any).stringifyTarget} can not be found`;
+		} else if (error as EntityNotFoundError) {
+			message = `${(error as any).stringifyTarget} could not be found`;
 			code = 404;
 		} else if (error instanceof FieldError) {
 			code = Number(error.code);
 			message = error.message;
 			errors = error.errors;
 		} else {
-			console.error(`[Error] ${code} ${req.url}`, errors || error, "body:", req.body);
+			console.error(`[Error] ${code} ${req.url}\n`, errors || error, "\nbody:", req.body);
 
 			if (req.server?.options?.production) {
 				// don't expose internal errors to the user, instead human errors should be thrown as HTTPError