Skip to content

Commit

Permalink
Dashboard load failure handling. Closes #70
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Khan committed Apr 29, 2014
1 parent 971668f commit 6af0ecd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/kibana/apps/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,16 @@ define(function (require) {
.when('/dashboard/:id', {
templateUrl: 'kibana/apps/dashboard/index.html',
resolve: {
dash: function (savedDashboards, $route) {
return savedDashboards.get($route.current.params.id);
dash: function (savedDashboards, Notifier, $route, $location, courier) {
return savedDashboards.get($route.current.params.id).catch(function (e) {
if (e instanceof courier.errors.SavedObjectNotFound) {
new Notifier({location: 'Dashboard'}).error(e.message);
$location.path('/dashboard');
return false;
} else {
throw e;
}
});
}
}
});
Expand Down
12 changes: 12 additions & 0 deletions src/kibana/components/courier/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,17 @@ define(function (require) {
errors.FieldNotFoundInCache);
};
inherits(errors.FieldNotFoundInCache, CourierError);

/**
* A saved object was not found
* @param {String} field - the fields which contains the conflict
*/
errors.SavedObjectNotFound = function SavedObjectNotFound(type) {
CourierError.call(this,
'Could not locate that ' + type,
errors.SavedObjectNotFound);
};
inherits(errors.SavedObjectNotFound, CourierError);

});
});
2 changes: 1 addition & 1 deletion src/kibana/components/saved_object/saved_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ define(function (require) {
// fetch the object from ES
return docSource.fetch()
.then(function applyESResp(resp) {
if (!resp.found) throw new Error('Unable to find that ' + type + '.');
if (!resp.found) throw new courier.errors.SavedObjectNotFound(type);

var meta = resp._source.kibanaSavedObjectMeta || {};
delete resp._source.kibanaSavedObjectMeta;
Expand Down

0 comments on commit 6af0ecd

Please sign in to comment.