DiscoverMeteor / book

17 stars 0 forks source link

Chapter 9.5: Code Snippets Mixed Up #445

Closed dustincoates closed 9 years ago

dustincoates commented 9 years ago

In 9.5 you have:

Meteor.call('postInsert', post, function(error, result) {
  if (error) {
    // display the error to the user
    Errors.throw(error.reason);

for post_submit.js and:

Posts.update(currentPostId, {$set: postProperties}, function(error) {
  if (error) {
    // display the error to the user
    Errors.throw(error.reason);

  // show this result but route anyway
  if (result.postExists)
    Errors.throw('This link has already been posted');

for post_edit.js.

Instead it should be:

    Meteor.call('postInsert', post, function(error, result) {
      // display the error to the user and abort
      if (error)
        return Errors.throw(error.reason);

      // show this result but route anyway
      if (result.postExists)
        Errors.throw('This link has already been posted');

for post_submit.js and:

    Posts.update(currentPostId, {$set: postProperties}, function(error) {
      if (error) {
        // display the error to the user
        Errors.throw(error.reason);

for post_edit.js.

SachaG commented 9 years ago

Thanks, we'll fix it :)