Skip to content

Commit

Permalink
Basic error reporting.
Browse files Browse the repository at this point in the history
chapter9-1
  • Loading branch information
tmeasday committed Oct 19, 2015
1 parent 2df3a7a commit 65dde1f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/helpers/errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Local (client-only) collection
Errors = new Mongo.Collection(null);

throwError = function(message) {
Errors.insert({message: message})
}
1 change: 1 addition & 0 deletions client/templates/application/layout.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template name="layout">
<div class="container">
{{> header}}
{{> errors}}
<div id="main">
{{> yield}}
</div>
Expand Down
14 changes: 14 additions & 0 deletions client/templates/includes/errors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template name="errors">
<div class="errors">
{{#each errors}}
{{> error}}
{{/each}}
</div>
</template>

<template name="error">
<div class="alert alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert">&times;</button>
{{message}}
</div>
</template>
5 changes: 5 additions & 0 deletions client/templates/includes/errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Template.errors.helpers({
errors: function() {
return Errors.find();
}
});

1 comment on commit 65dde1f

@qiulang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel rather confused now, why we put throwError function in client/helpers/errors.js, why not in client/templates/includes/errors.js ? After all they are both inside client folder ?

throwError = function(message) {
   Errors.insert({message: message})
} 

Please sign in to comment.