summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-04-19 01:27:19 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-04-19 01:27:19 +1000
commit40ad7bb3af15a3658de4f9b43fbc0678d71c1dd8 (patch)
treef52c0eb6bb238d5c3082c8c1069334eb424c44c2 /src
parentFix UserRelationsResponse schema (diff)
parentREALLY bad server testing (diff)
downloadserver-40ad7bb3af15a3658de4f9b43fbc0678d71c1dd8.tar.xz
Merge branch 'master' into openapi
Diffstat (limited to 'src')
-rw-r--r--src/api/middlewares/ErrorHandler.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/api/middlewares/ErrorHandler.ts b/src/api/middlewares/ErrorHandler.ts
index b8a73298..c417e64f 100644
--- a/src/api/middlewares/ErrorHandler.ts
+++ b/src/api/middlewares/ErrorHandler.ts
@@ -22,7 +22,7 @@ import { ApiError, FieldError } from "@spacebar/util";
 const EntityNotFoundErrorRegex = /"(\w+)"/;
 
 export function ErrorHandler(
-	error: Error,
+	error: Error & { type?: string },
 	req: Request,
 	res: Response,
 	next: NextFunction,
@@ -50,6 +50,11 @@ export function ErrorHandler(
 			code = Number(error.code);
 			message = error.message;
 			errors = error.errors;
+		} else if (error?.type == "entity.parse.failed") {
+			// body-parser failed
+			httpcode = 400;
+			code = 50109;
+			message = "The request body contains invalid JSON.";
 		} else {
 			console.error(
 				`[Error] ${code} ${req.url}\n`,