Add validation and return error the the tracker does not existe

This commit is contained in:
Viridiana J Amezcua Orona 2017-01-16 11:21:03 -06:00
parent f2a471f285
commit ac20d7759b
1 changed files with 9 additions and 6 deletions

View File

@ -32,11 +32,8 @@ module.exports = function(UserStory) {
return item.id == id;
})
if(file.length > 0){
file = file[0];
}else{
file = 'The file with id: '+ id +' does not exist.'
}
file = (file.length > 0)?file[0]:null;
return file;
};
@ -299,7 +296,13 @@ module.exports = function(UserStory) {
UserStory.findById = function(id, params, cb){
var userStory = getFileById(id);
parseUserStory(userStory, cb);
if(userStory){
parseUserStory(userStory, cb);
}else{
cb('File does not exist', null);
}
};//end find by id