Meteor-Community-Packages / meteor-publication-collector

Test a Meteor publication by collecting its output.
https://atmospherejs.com/johanbrook/publication-collector
MIT License
33 stars 20 forks source link

Error: Cannot read property 'call' of undefined #35

Closed rockettomatooo closed 6 years ago

rockettomatooo commented 6 years ago

Hey Johan,

I recently came across a very missleading error from this package

Error: Cannot read property 'call' of undefined
    at PublicationCollector.collect (packages/johanbrook:publication-collector/publication-collector.js:67:28)
    ....

which refers to those 2 lines:

collect(name, ...args) {
  ...

  const handler = Meteor.server.publish_handlers[name];
  const result = handler.call(this, ...args);

  ...
}

It turns out I "just" misspelled my publication which apperantly caused the read error.

Due to the thrown error, it took me a little while to figure out what caused the error _(also because I'm not familiar with publish_handlers or meteor internals in generall)_. Therefor I would love to get a more specific error message suggesting that I eventually misspelled the publication.

Unfortunately, I'm busy right now and therefor not able to provide a pull request. Sorry!

johanbrook commented 6 years ago

Hey!

True, we should totally do a guard check there. Thanks!