diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-04-19 01:27:19 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-04-19 01:27:19 +1000 |
commit | 40ad7bb3af15a3658de4f9b43fbc0678d71c1dd8 (patch) | |
tree | f52c0eb6bb238d5c3082c8c1069334eb424c44c2 /src | |
parent | Fix UserRelationsResponse schema (diff) | |
parent | REALLY bad server testing (diff) | |
download | server-40ad7bb3af15a3658de4f9b43fbc0678d71c1dd8.tar.xz |
Merge branch 'master' into openapi
Diffstat (limited to 'src')
-rw-r--r-- | src/api/middlewares/ErrorHandler.ts | 7 |
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`, |