Return an error from method


#1

on the client:

Meteor.call('foo', bar, function(error, result) {
  if (error)
    console.log('something went wrong');
});

on the server:

Meteor.methods({
  foo: function(bar) {
    if (test stuff) {
      // works
    } else {
      // return error
    };
  }
});

is there a way to return an error inside the method eg. using the error parameter of the method function?


#2

You want Meteor.Error: http://docs.meteor.com/#/full/meteor_error