From 0c59ad5cfc2dfef9c1bb9c5deaacde72ad593d8e Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Thu, 12 Aug 2021 16:45:41 +0200 Subject: [PATCH] :pencil: improve error message --- src/models/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/models/index.ts b/src/models/index.ts index 0ef98af0..d0a46bf9 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -56,7 +56,10 @@ mongoose.plugin((schema: Schema, opts: any) => { try { // @ts-ignore const isExistsQuery = JSON.stringify(this._userProvidedFields) === JSON.stringify({ _id: 1 }); - if (!doc && !isExistsQuery) return next(new HTTPError("Not found", 404)); + if (!doc && !isExistsQuery) { + // @ts-ignore + return next(new HTTPError(`${this?.mongooseCollection?.name}.${this?._conditions?.id} not found`, 400)); + } // @ts-ignore return next(); } catch (error) {