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

@@ -32,7 +32,7 @@ func DatastreamNames(conf *cfg.Config) ([]string, error) {
res, err := conf.DefaultCluster.ES().Indices.GetDataStream().
Do(context.Background())
if err != nil {
return nil, fmt.Errorf("failed to get data streams: %s", esErrorString(err))
return nil, fmt.Errorf("failed to get data streams: %w", esErrorString(err))
}
dss := make([]string, len(res.DataStreams))
@@ -47,7 +47,7 @@ func DatastreamList(conf *cfg.Config) error {
res, err := conf.DefaultCluster.ES().Indices.GetDataStream().
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get data streams: %s", esErrorString(err))
return fmt.Errorf("failed to get data streams: %w", esErrorString(err))
}
slog.Debug("ES result", "data streams", res)
@@ -128,7 +128,7 @@ func DatastreamShow(conf *cfg.Config, dsname string) error {
Name(dsname).
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get data stream: %s", esErrorString(err))
return fmt.Errorf("failed to get data stream: %w", esErrorString(err))
}
slog.Debug("ES result", "data stream", res)
@@ -141,7 +141,7 @@ func DatastreamShow(conf *cfg.Config, dsname string) error {
Name(dsname).
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get data stream stats: %s", esErrorString(err))
return fmt.Errorf("failed to get data stream stats: %w", esErrorString(err))
}
table := printer.NewTable(conf, 11, 2)
@@ -208,7 +208,7 @@ func DatastreamCreate(conf *cfg.Config, dsname string) error {
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to create datastream: %s", esErrorString(err))
return fmt.Errorf("failed to create datastream: %w", esErrorString(err))
}
return nil
@@ -219,7 +219,7 @@ func DatastreamDelete(conf *cfg.Config, dsname string) error {
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to delete datastream: %s", esErrorString(err))
return fmt.Errorf("failed to delete datastream: %w", esErrorString(err))
}
return nil
@@ -229,7 +229,7 @@ func DatastreamRollover(conf *cfg.Config, ds string) error {
res, err := RolloverAlias(conf, ds)
if err != nil {
return fmt.Errorf("failed to rollover data stream: %s", esErrorString(err))
return fmt.Errorf("failed to rollover data stream: %w", esErrorString(err))
}
table := printer.NewTable(conf, 2, 5)