From 816d38172b37ec2177fccf06cab746ad27bd452c Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Mon, 8 Apr 2013 12:00:19 +1000 Subject: [PATCH] Actually use the error reporting. chapter9-2 --- client/templates/posts/post_edit.js | 4 ++-- client/templates/posts/post_submit.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/templates/posts/post_edit.js b/client/templates/posts/post_edit.js index ffb9da64..4787ed57 100644 --- a/client/templates/posts/post_edit.js +++ b/client/templates/posts/post_edit.js @@ -12,7 +12,7 @@ Template.postEdit.events({ Posts.update(currentPostId, {$set: postProperties}, function(error) { if (error) { // display the error to the user - alert(error.reason); + throwError(error.reason); } else { Router.go('postPage', {_id: currentPostId}); } @@ -28,4 +28,4 @@ Template.postEdit.events({ Router.go('postsList'); } } -}); \ No newline at end of file +}); diff --git a/client/templates/posts/post_submit.js b/client/templates/posts/post_submit.js index 33a3c8a8..6c2a7a4b 100644 --- a/client/templates/posts/post_submit.js +++ b/client/templates/posts/post_submit.js @@ -10,11 +10,11 @@ Template.postSubmit.events({ Meteor.call('postInsert', post, function(error, result) { // display the error to the user and abort if (error) - return alert(error.reason); + return throwError(error.reason); // show this result but route anyway if (result.postExists) - alert('This link has already been posted'); + throwError('This link has already been posted'); Router.go('postPage', {_id: result._id}); });