How to handle errors in a single page?

Hello everyone,

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.

Could someone help me how to do it.

Thanks in advance.

if I understood well. This is custom error page

// client/checkUser.js

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;
}
}
})

// common/error

throwError = function(message) {
Session.set(‘error’,message);
Router.go(‘errors’);
};

// common/router.js

Router.route(’/error’, {name: ‘errors’});

// client/erros.js

Template.errors.helpers({
error: function() {
return Session.get(‘error’);
}
});

//client/views/error.html

{{error}}