diff options
author | xnacly <matteogropp@protonmail.com> | 2021-09-03 20:00:19 +0200 |
---|---|---|
committer | xnacly <matteogropp@protonmail.com> | 2021-09-03 20:00:19 +0200 |
commit | 787b830a09dd07a6c1e420a0785b9713a012edba (patch) | |
tree | 6465d5187e20a24b9c007dc3ec029789ef39c847 /api | |
parent | Merge pull request #314 from AlTech98/master (diff) | |
download | server-787b830a09dd07a6c1e420a0785b9713a012edba.tar.xz |
fixed 'undefined not found' + error not showing in client
Diffstat (limited to 'api')
-rw-r--r-- | api/src/middlewares/ErrorHandler.ts | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/api/src/middlewares/ErrorHandler.ts b/api/src/middlewares/ErrorHandler.ts index 34827cab..d8e44bd7 100644 --- a/api/src/middlewares/ErrorHandler.ts +++ b/api/src/middlewares/ErrorHandler.ts @@ -19,8 +19,8 @@ export function ErrorHandler(error: Error, req: Request, res: Response, next: Ne code = error.code; message = error.message; httpcode = error.httpStatus; - } else if (error as EntityNotFoundError) { - message = `${(error as any).stringifyTarget} could not be found`; + } else if (error instanceof EntityNotFoundError) { + message = `${(error as any).stringifyTarget || "Item"} could not be found`; code = 404; } else if (error instanceof FieldError) { code = Number(error.code); |