summary refs log tree commit diff
path: root/api/src/middlewares/ErrorHandler.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-04 11:26:47 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-04 11:26:47 +0200
commite9a88852825fe3c6509456c2f7533889bd3c138c (patch)
tree732bd2cd6eacaa309800b764fb3b08003954065e /api/src/middlewares/ErrorHandler.ts
parent:bug: api member add roles -> make sure that roles exist (diff)
parentfixed /discoverable-guilds (diff)
downloadserver-e9a88852825fe3c6509456c2f7533889bd3c138c.tar.xz
Merge branch 'master' of https://github.com/fosscord/fosscord-api
Diffstat (limited to 'api/src/middlewares/ErrorHandler.ts')
-rw-r--r--api/src/middlewares/ErrorHandler.ts5
1 files changed, 2 insertions, 3 deletions
diff --git a/api/src/middlewares/ErrorHandler.ts b/api/src/middlewares/ErrorHandler.ts

index 179c5991..be2586cf 100644 --- a/api/src/middlewares/ErrorHandler.ts +++ b/api/src/middlewares/ErrorHandler.ts
@@ -2,9 +2,8 @@ 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 "@fosscord/util"; -// TODO: update with new body/typorm validation export function ErrorHandler(error: Error, req: Request, res: Response, next: NextFunction) { if (!error) return next(); @@ -20,7 +19,7 @@ export function ErrorHandler(error: Error, req: Request, res: Response, next: Ne message = error.message; httpcode = error.httpStatus; } else if (error instanceof EntityNotFoundError) { - message = `${(error as any).stringifyTarget} could not be found`; + message = `${(error as any).stringifyTarget || "Item"} could not be found`; code = 404; } else if (error instanceof FieldError) { code = Number(error.code);