I have a route /users/:user_id in emberjs application and I am assigning a model to the template in setupController hook of a App.UserRoute class as:
controller.store.find('user', model.id).then(onSuccess, onError);
var onSuccess = function(user) {
if(user) {
// reload Model to forcefully fetch from server
user.reload().then(function() { /* some processing */ }, function(error_response) { /* some error handling */ });
// assign model for user
controller.set('model', user);
}
};
var onError = function(reason) { /* some error handling */ };
Now this gives me an error 404 from server when I am looking for an user-id which does not exists. I am trying to catch this error and display appropriate message and redirect to the list of all users (/users). But I am unable to catch it and I get an error from ember : Error while loading route: undefined. How can I achieve this?