From 8898d7aab9565c48162c5cf16bfdf2f6f74cdb1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Mon, 24 Sep 2018 09:22:29 +0200 Subject: Idiomatic error handling for app/e*.go (#9426) --- app/elasticsearch.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'app/elasticsearch.go') diff --git a/app/elasticsearch.go b/app/elasticsearch.go index c3b558bce..2e731f5d7 100644 --- a/app/elasticsearch.go +++ b/app/elasticsearch.go @@ -18,27 +18,28 @@ func (a *App) TestElasticsearch(cfg *model.Config) *model.AppError { } } - if esI := a.Elasticsearch; esI != nil { - if err := esI.TestConfig(cfg); err != nil { - return err - } - } else { + esI := a.Elasticsearch + if esI == nil { err := model.NewAppError("TestElasticsearch", "ent.elasticsearch.test_config.license.error", nil, "", http.StatusNotImplemented) return err } + if err := esI.TestConfig(cfg); err != nil { + return err + } return nil } func (a *App) PurgeElasticsearchIndexes() *model.AppError { - if esI := a.Elasticsearch; esI != nil { - if err := esI.PurgeIndexes(); err != nil { - return err - } - } else { + esI := a.Elasticsearch + if esI == nil { err := model.NewAppError("PurgeElasticsearchIndexes", "ent.elasticsearch.test_config.license.error", nil, "", http.StatusNotImplemented) return err } + if err := esI.PurgeIndexes(); err != nil { + return err + } + return nil } -- cgit v1.2.3-1-g7c22