From 95a6e4e87cc5616a5ad9705954b57e973450bffa Mon Sep 17 00:00:00 2001 From: wangzhezhe Date: Mon, 4 Jan 2016 13:15:16 +0800 Subject: [PATCH 1/2] replace pannic with fmt.Errorf in elasticsearch storage --- storage/elasticsearch/elasticsearch.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/storage/elasticsearch/elasticsearch.go b/storage/elasticsearch/elasticsearch.go index 6a3f0c40..c5169a15 100644 --- a/storage/elasticsearch/elasticsearch.go +++ b/storage/elasticsearch/elasticsearch.go @@ -103,7 +103,8 @@ func (self *elasticStorage) AddStats(ref info.ContainerReference, stats *info.Co Do() if err != nil { // Handle error - panic(fmt.Errorf("failed to write stats to ElasticSearch- %s", err)) + fmt.Errorf("failed to write stats to ElasticSearch - %s", err) + return } }() return nil @@ -135,14 +136,15 @@ func newStorage( ) if err != nil { // Handle error - panic(err) + return nil, fmt.Errorf("failed to create the elasticsearch client - %s", err) } // Ping the Elasticsearch server to get e.g. the version number info, code, err := client.Ping().URL(elasticHost).Do() if err != nil { // Handle error - panic(err) + return nil, fmt.Errorf("failed to ping the elasticsearch - %s", err) + } fmt.Printf("Elasticsearch returned with code %d and version %s", code, info.Version.Number) From 768aba06cfbfedce72bfc56545c1f7cf77c35877 Mon Sep 17 00:00:00 2001 From: wangzhezhe Date: Mon, 4 Jan 2016 13:49:26 +0800 Subject: [PATCH 2/2] replace panic with fmt --- storage/elasticsearch/elasticsearch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/elasticsearch/elasticsearch.go b/storage/elasticsearch/elasticsearch.go index c5169a15..b43beed2 100644 --- a/storage/elasticsearch/elasticsearch.go +++ b/storage/elasticsearch/elasticsearch.go @@ -103,7 +103,7 @@ func (self *elasticStorage) AddStats(ref info.ContainerReference, stats *info.Co Do() if err != nil { // Handle error - fmt.Errorf("failed to write stats to ElasticSearch - %s", err) + fmt.Printf("failed to write stats to ElasticSearch - %s", err) return } }()