In Meteor, what's the difference between this.error and throwing a new Meteor.Error in Meteor.publish?

In Meteor.publishwhat is the difference between using this.errorand simply throwing Meteor.Error?

+5
source share
2 answers

this.erroravailable only inside the publish method. Per:

Terminates this client subscription, causing the client to call the callback onErrorpassed to Meteor.subscribe, if any. If the error is not Meteor.Error, it will be displayed on Meteor.Error(500, "Internal server error").

Meteor.Error , . , , Meteor , - , this.error, .

+6

, . :

try {
  var res = self._handler.apply(self, EJSON.clone(self._params));
} catch (e) {
  self.error(e);
  return;
}

, , error. error .

+2

All Articles