We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 697c333 commit 500b396Copy full SHA for 500b396
elasticsearch/client/client.go
@@ -3,6 +3,7 @@ package client
3
import (
4
"github.com/Trendyol/go-pq-cdc-elasticsearch/config"
5
"github.com/elastic/go-elasticsearch/v7"
6
+ "github.com/go-playground/errors"
7
)
8
9
func NewClient(config *config.Config) (*elasticsearch.Client, error) {
@@ -21,9 +22,14 @@ func NewClient(config *config.Config) (*elasticsearch.Client, error) {
21
22
return nil, err
23
}
24
- if _, err = client.Ping(); err != nil {
25
+ r, err := client.Ping()
26
+ if err != nil {
27
28
29
30
+ if r.StatusCode == 401 {
31
+ return nil, errors.New("unauthorized")
32
+ }
33
+
34
return client, nil
35
0 commit comments