Browse Source

Commit 9-2: Actually use the error reporting.

- Updated fixture to include author names.
Frederic G. MARAND 9 năm trước cách đây
mục cha
commit
3bf737c58a

+ 2 - 4
client/templates/posts/post_edit.js

@@ -19,12 +19,10 @@ Template.postEdit.events({
     };
     };
 
 
 
 
-    Posts.update(currentPostId, {
-      $set: postProperties
-    },function (error) {
+    Posts.update(currentPostId, { $set: postProperties },function (error) {
       // Display the error to the user and abort.
       // Display the error to the user and abort.
       if (error) {
       if (error) {
-        return alert(error.reason);
+        return throwError(error.reason);
       }
       }
       else {
       else {
         Router.go('postPage', { _id: currentPostId });
         Router.go('postPage', { _id: currentPostId });

+ 2 - 2
client/templates/posts/post_submit.js

@@ -19,10 +19,10 @@ Template.postSubmit.events({
     Meteor.call('postInsert', post, function (error, result) {
     Meteor.call('postInsert', post, function (error, result) {
       // Display the error to the user and abort.
       // Display the error to the user and abort.
       if (error) {
       if (error) {
-        return alert(error);
+        return throwError(error.reason);
       }
       }
       if (result.postExists) {
       if (result.postExists) {
-        alert("This link has already been posted");
+        throwError("This link has already been posted");
       }
       }
 
 
       Router.go('postPage', { _id: result._id });
       Router.go('postPage', { _id: result._id });

+ 6 - 3
server/fixtures.js

@@ -11,15 +11,18 @@ if (Posts.find().count() === 0) {
   var data = [
   var data = [
     {
     {
       title: "Introducing Telescope",
       title: "Introducing Telescope",
-      url: "http://sachagreif.com/introducing-telescope"
+      url: "http://sachagreif.com/introducing-telescope",
+      author: "Sacha Greif"
     },
     },
     {
     {
       title: "Meteor",
       title: "Meteor",
-      url: "http://meteor.com"
+      url: "http://meteor.com",
+      author: "Tom Coleman"
       },
       },
     {
     {
       title: "The Meteor book",
       title: "The Meteor book",
-      url: "http://themeteorbook.com"
+      url: "http://themeteorbook.com",
+      author: "Meteor Inc."
       }
       }
   ];
   ];