I am using bluebird promise and standard-error. Issue is when i throw error like this
return new PromiseReturns(function (resolve, reject) {
reject(new StandardError({
status: 'Error',
message: "Not Found",
originalError: err,
code: 404
}));
});
it doesn't recieved in this catch
.catch(StandardError , function(err){
})
instead its recieved in
.catch(function(err){
})
Create new PromiseReturns each time was causing the issue. I have bundled all my code in one single promise and that worked.
for example:
function requestFromController(body){
return new PromiseReturns(function (resolve, reject) {
if(body){
reject(new StandardError({
status: 'Error',
message: "Not Found",
originalError: err,
code: 404
}));
}
db.model.find().then(x => {
resolve(x);
})
});
}