wrap errors correctly

This commit is contained in:
2026-07-07 09:34:36 +02:00
parent 24038e36f7
commit 2f77c27715
22 changed files with 95 additions and 94 deletions

View File

@@ -29,7 +29,7 @@ func getRemoteName(conf *cfg.Config) (string, error) {
res, err := conf.DefaultCluster.ES().Cluster.RemoteInfo().
Do(context.Background())
if err != nil {
return "", fmt.Errorf("failed to retrieve follower info: %s", esErrorString(err))
return "", fmt.Errorf("failed to retrieve follower info: %w", esErrorString(err))
}
remote := ""
@@ -91,7 +91,7 @@ func CcrFollowerResume(conf *cfg.Config, index string) error {
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to resume ccr following: %s", esErrorString(err))
return fmt.Errorf("failed to resume ccr following: %w", esErrorString(err))
}
return nil
@@ -102,7 +102,7 @@ func CcrFollowerPause(conf *cfg.Config, index string) error {
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to pause ccr following: %s", esErrorString(err))
return fmt.Errorf("failed to pause ccr following: %w", esErrorString(err))
}
return nil
@@ -113,7 +113,7 @@ func CcrFollowerUnfollow(conf *cfg.Config, index string) error {
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to unfollow index: %s", esErrorString(err))
return fmt.Errorf("failed to unfollow index: %w", esErrorString(err))
}
return nil
@@ -136,7 +136,7 @@ func CcrFollowerAdd(conf *cfg.Config, index string) error {
_, err = create.Do(context.Background())
if err != nil {
return fmt.Errorf("failed to create follower index: %s", esErrorString(err))
return fmt.Errorf("failed to create follower index: %w", esErrorString(err))
}
return nil
@@ -146,17 +146,17 @@ func CcrFollowerShow(conf *cfg.Config, index string) error {
res, err := conf.DefaultCluster.ES().Ccr.FollowStats(index).
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to retrieve follower index info: %s", esErrorString(err))
return fmt.Errorf("failed to retrieve follower index info: %w", esErrorString(err))
}
slog.Debug("ES result", "follower stats", res.Indices)
if len(res.Indices) == 0 {
return fmt.Errorf("cluster did not return any follower stats for index %s", index)
return fmt.Errorf("cluster did not return any follower stats for index %w", index)
}
if len(res.Indices[0].Shards) == 0 {
return fmt.Errorf("cluster did not return any shard stats on follower index %s", index)
return fmt.Errorf("cluster did not return any shard stats on follower index %w", index)
}
follower := res.Indices[0].Shards[0]