Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
Don't return stack errors to client
Browse files Browse the repository at this point in the history
related to #612
  • Loading branch information
mohammadranjbarz committed Sep 14, 2021
1 parent 1c3301f commit fc416fe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app.hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const convertVerifiedToBoolean = () => context => {
return context;
};

const changeMongoErrors = () => context => {
const parseErrors = () => context => {
// verified field is boolean in Trace, Campaign and Community so for getting this filter
// in query string we should cast it to boolean here
if (context.error.message.includes('Invalid query parameter')) {
Expand All @@ -69,6 +69,11 @@ const changeMongoErrors = () => context => {
logger.info('Mongo error in feathers call', context.error);
throw new errors.BadRequest(errorMessages.INVALID_INPUT_DATA);
}
if (context.error.stack) {
// Should not return stack error to client
logger.info('Error with stack', context.error);
throw new errors.GeneralError();
}
return context;
};

Expand Down Expand Up @@ -123,7 +128,7 @@ module.exports = {
},

error: {
all: [responseLoggerHook(), changeMongoErrors()],
all: [responseLoggerHook(), parseErrors()],
find: [],
get: [],
create: [],
Expand Down

0 comments on commit fc416fe

Please sign in to comment.