diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-09-24 09:22:29 +0200 |
---|---|---|
committer | Sudheer <sudheer.105@gmail.com> | 2018-09-24 12:52:29 +0530 |
commit | 8898d7aab9565c48162c5cf16bfdf2f6f74cdb1e (patch) | |
tree | 33badb2352d3917cb40ec5cac402768e2b15cff8 /app/elasticsearch.go | |
parent | 74c92237c04ff290770469be516102c896710e12 (diff) | |
download | chat-8898d7aab9565c48162c5cf16bfdf2f6f74cdb1e.tar.gz chat-8898d7aab9565c48162c5cf16bfdf2f6f74cdb1e.tar.bz2 chat-8898d7aab9565c48162c5cf16bfdf2f6f74cdb1e.zip |
Idiomatic error handling for app/e*.go (#9426)
Diffstat (limited to 'app/elasticsearch.go')
-rw-r--r-- | app/elasticsearch.go | 21 |
1 files changed, 11 insertions, 10 deletions
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 } |