Browse Source

Commit 9-2: Actually use the error reporting.

- Updated fixture to include author names.
Frederic G. MARAND 9 years ago
parent
commit
3bf737c58a
3 changed files with 10 additions and 9 deletions
  1. 2 4
      client/templates/posts/post_edit.js
  2. 2 2
      client/templates/posts/post_submit.js
  3. 6 3
      server/fixtures.js

+ 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.
       if (error) {
-        return alert(error.reason);
+        return throwError(error.reason);
       }
       else {
         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) {
       // Display the error to the user and abort.
       if (error) {
-        return alert(error);
+        return throwError(error.reason);
       }
       if (result.postExists) {
-        alert("This link has already been posted");
+        throwError("This link has already been posted");
       }
 
       Router.go('postPage', { _id: result._id });

+ 6 - 3
server/fixtures.js

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