diff options
Diffstat (limited to 'api/src/middlewares/ErrorHandler.ts')
-rw-r--r-- | api/src/middlewares/ErrorHandler.ts | 5 |
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); |