How to get simpleschema validation errors when doing latency compensation

Hello

I have the following method defined on both the client and server

Meteor.methods({
  createComment(comment) {
    const { graphId, postingId, text, service } = comment;
    const _commentId = Comments.insert(comment);

    if (Meteor.isServer) {
      this.unblock();

      const userId = Meteor.userId();
      const graph  = Graph.findUserGraph({ userId, graphId })
      const data   = { postingId, graphId: graph.graphId, message: text, tokens: graph.auth }

      const comment = Social.reply(service, data);
      Comments.upsert({ _id: _commentId }, { $set: comment });
    }
  }
});

For example, if no text is entered, simple schema throws a Text is required error, but I am not sure how to capture it. I tryied wrapping the method in a try-catch expression, but for some reason, only the serverside code catches the exception.

Use the callbacks that collection2 attaches to collection mutators

Comments.insert({/* doc */}, function(error,result){
  if (error) throw new Meteor.Error('400', error.invalidKeys);
})

since you are throwing a Meteor.Error, it propagates back to the client and within your method call callback, you can reach it

Method.call('createComment', comment, function(error,result) {}
  if (error) {
    /* do something with error.reason */
  }
)

I guess I was to quick to pass judgement. Take a look at https://github.com/aldeed/meteor-collection2/issues/206

which basically says run the insert synchronously (without the callback) and the error should itself propagate up to the client in the error.details