Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>@colymba got it almost right, but I'll try to make a more elaborated answer so it helps you get up and running easier. </p> <p>As already stated in the new <a href="https://gist.github.com/machty/5647589" rel="noreferrer">router facelift</a> when an attempt is made to transition into a route, any of the hooks <code>beforeModel</code>, <code>model</code> and <code>afterModel</code> may throw an error, or return a promise that rejects, in this case an <code>error</code> event will be fired on the <em>partially</em> entered route, allowing you to handle errors on a per route basis.</p> <pre><code>App.SomeRoute = Ember.Route.extend({ model: function() { //assuming the model hook rejects due to an error from your backend }, events: { // then this hook will be fired with the error and most importantly a Transition // object which you can use to retry the transition after you handled the error error: function(error, transition) { // handle the error console.log(error.message); // retry the transition transition.retry(); } }); </code></pre> <p>In the case you want to have errors be handled application wide you can define your own global default <code>error</code> handler by overriding the <code>error</code> handler on the <code>ApplicationRoute</code>, this could look something like this:</p> <pre><code>App.ApplicationRoute = Ember.Route.extend({ events: { error: function(error, transition) { // handle the error console.log(error.message); } } }); </code></pre> <p>Take into account that by default, an event will stop bubbling once a handler defined on the <code>events</code> hash handles it. But to continue bubbling the event all the way up to the <code>ApplicationRoute</code> you should return <code>true</code> from that handler, so it can notify more <code>error</code> handler from which you can then retry to make the transition to the route with <code>transition.retry()</code>.</p> <h2>Update for ember 1.0 and upwards</h2> <p>Since the new ember release 1.0, the <code>events</code> hash was renamed to <code>actions</code>. A route's error handler should be in the <code>actions</code> hash now:</p> <pre><code>App.ApplicationRoute = Ember.Route.extend({ actions: { error: function(error, transition) { // handle the error console.log(error.message); } } }); </code></pre> <p>Hope this helps you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload