Skip to content

Commit

Permalink
Add error handling for missing elasticsearch index. Closes elastic#7
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Khan committed Sep 2, 2015
1 parent edba8af commit 9f23524
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions series_functions/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ module.exports = new Datasource('es', {
var body = buildRequest(config, tlConfig);
return client.search(body).then(function (resp) {

if (!resp._shards.total) throw new Error('Elasticsearch index not found: ' + config.index);

var data = _.map(resp.aggregations.series.buckets, function (bucket) {
var value;
if (resp.aggregations.series.buckets[0].metric != null) {
Expand Down

0 comments on commit 9f23524

Please sign in to comment.