Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

default error template on Ember not loading

I'm not sure if I'm doing something wrong, but at my ApplicationRoute I have something like that:

actions: {
    error: function(error, transition) {
        var self = this;
        metadata = {
            'timeout': {
                action: function(error, transition) {
                   BootstrapDialog.alert({message: 'Request Timeout!'});
                }
            },
            'forbidden': {
                action: function(error, transition) {
                    self.transitionTo('companies');
                }
            },
            'unauthorized': {
                action: function(error, transition) {
                    window.location.replace(error.responseJSON.redirect_url);
                }
            },
            'bad gateway': {
                action: function(error, transition) {
                    throw new Error("Error");
                }
            }
        };

        if(error.statusText.toLowerCase() in metadata) {
            metadata[error.statusText.toLowerCase()].action(error, transition);
        }
    }
}

and I have a error.hbs templete, which I expect to be fired on 'bad gateway' error, but the template doesn't load, there is any specific way for me to load the default error template?

Thanks.

like image 312
Gustavo Siqueira Avatar asked Dec 16 '25 15:12

Gustavo Siqueira


1 Answers

If you define the application error handler, you must render the error template.

App.ApplicationRoute = Ember.Route.extend({
  actions: {
    error: function() {

      this.render('error', {
        into: 'application'
      });
    }
  }

});

An example is available here.

You could remove the error handler and check how the error template is rendered by ember.

like image 162
ppcano Avatar answered Dec 19 '25 06:12

ppcano



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!