I am having an issue where I want to return a default value if an exception occurs on a promise. The array I return does not seem to work properly.
My Route model hook
model: function() {
return {
menuItems : this.store.find('menuItem').catch(function(error) {
Ember.Logger.error('Retrieving Menu Items', error);
return [];
}),
My controller mode
selectFirstMenuItem: function() {
var model = this.get('model');
//At this point model.menuItems is some weird object
//with an _id : 26, _label : undefined, _result: Array(0), _state : 1 etc.
//(maybe a Promise?), the .get method throws an undefined exception.
if(model.menuItems.get('length') > 0 ) {
...
}
}.observes('model.menuItems.@each'),