Default Error Page

I want to define the default error page in meteor. That is, if the application crashes or another error occurs, the user should be redirected to a "friendly" page that says something like: the system is unavailable, refer to etc. Etc. Is there a way to do this or something like that?

thank

0
meteor
Jul 16 '12 at 9:16
source share
1 answer

For routing you need to use BackboneJS ( Backbone Router ). With this code, the session variable 'page_type' will tell you if you have the wrong URL.

var BackboneRouter = Backbone.Router.extend({ routes: { "/": "default", ":error": "list" }, default: function () { Session.set("page_type", "default"); }, error: function () { Session.set("page_type", "error"); } }); Router = new BackboneRouter; Meteor.startup(function () { Backbone.history.start({pushState: true}); }); 

Now you can use "page_type" to tell the template engine which template to load.

 Template.tmp.route = function () { if (Session.get("page_type") == "default") { return true; } else { return false; } <template name="tmp"> {{#if route}} {{> default}} {{else}} {{> error}} {{/if}} </template> 
+2
Jul 16 '12 at 22:12
source share



All Articles