diff --git a/src/auth-service/models/User.js b/src/auth-service/models/User.js index ba0797063c..66d79d969e 100644 --- a/src/auth-service/models/User.js +++ b/src/auth-service/models/User.js @@ -786,7 +786,10 @@ UserSchema.statics = { } } catch (error) { logger.error(`🐛🐛 Internal Server Error -- ${error.message}`); - next( + if (error instanceof HttpError) { + return next(error); + } + return next( new HttpError( "Internal Server Error", httpStatus.INTERNAL_SERVER_ERROR, @@ -997,7 +1000,10 @@ UserSchema.statics = { } } catch (error) { logger.error(`🐛🐛 Internal Server Error -- ${error.message}`); - next( + if (error instanceof HttpError) { + return next(error); + } + return next( new HttpError( "Internal Server Error", httpStatus.INTERNAL_SERVER_ERROR, @@ -1039,6 +1045,9 @@ UserSchema.statics = { ); } catch (error) { logger.error(`🐛🐛 Internal Server Error -- ${error.message}`); + if (error instanceof HttpError) { + return next(error); + } return next( new HttpError( "Internal Server Error", @@ -1078,7 +1087,10 @@ UserSchema.statics = { } catch (error) { logObject("the models error", error); logger.error(`🐛🐛 Internal Server Error -- ${error.message}`); - next( + if (error instanceof HttpError) { + return next(error); + } + return next( new HttpError( "Internal Server Error", httpStatus.INTERNAL_SERVER_ERROR,