I’m new to meteor. I’ve been exploring all the new concepts and the working flow of the program in meteor. It’s very interesting.
Now, here is the issue, I wanted to place all the error handling code in one page (which contains various errors like 404 page not found, user not found) and I want to reflect to this single page for any error in any page and show the relevant message from the error page according to the error.
Template.checkUser.evets({
‘click .btn’:function(){
id = Meteor.userId();
Meteor.call(‘checkUser’,id,function(err,response){
if(err){
throwError(err.reason);
}else{
// do somethink if user exist
}
});
}
})
// server/checkUser.js
Meteor.methods({
checkUser:function(id){
var user = User.findOne(id);
if(!user){
throw new Meteor.Error( 404, ‘User not found’ );
}else{
return user;
}
}
})