How to return error from Meteor.methods function

Viewed 7136

how to return error from Meteor.methods function? I call my function:

Meteor.call('checkCode', mycode, function(error,result){
    console.log(result['name']);
  })

And it returns me name of person whose "code" is the same as argument. But how return an error if there is nobody with input code? My function code:

checkCode: function(zcode){
    return Codes.findOne({code: zcode});
  }

Thanks!:)

1 Answers
Related