How to display a full page error in Ember.js using errors?

I am using Ember.js and ember-cli v2.7.0 .

As indicated in Ember's Guide on the "Download and error", you can react to errors that occur during processing beforeModel, modeland / or afterModelintercepts, creating effects error, eg:

export default Ember.Route.extend({
  actions: {

    error(err, transitionTo) {
      if (err) {
        return this.transitionTo('error');
      }
    }

  }
  ...
}

If I put this action with an error in the routes / application.js route , I can supposedly be able to respond to errors that occur in any of these hooks.

My goal...

, , , , - .

, URL-. , - : http://myemberapp.com/some/path ( - ), , 404, 500, {{outlet}} .

, ...

wt this.transitionTo, , () . err, (model) transitionTo !

...

, this.transitionTo , , "inline" , , , (routes/error.js), , . , , err, .

, , , , .

, , , , err, . JSONAPI, ( JSON), javascript, . null.boom , . ? , - 404, 500 - .

( , Ember 404 , URL-, ? Globbing ?)

, , - , . some.child.route , , , .

, Ember.js, , , , .

, , Ember.js, 2.x?

( !)


(2016/08/18):

lastError , . ? .

error(err, transitionTo) {
  let errorController = this.controllerFor("error")
  errorController.set("lastError", err);
  this.transitionTo("error");
},
+4
1

, .

    {{#if error}}
      <div class="error">{{error}}</div>
    {{else}}
      {{outlet}}
    {{/if}}
0

Source: https://habr.com/ru/post/1651627/


All Articles