From 3b8a98bb83ba2b6809fc333d0584d96160b2524a Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Sun, 28 Jan 2024 16:34:19 +0000 Subject: [PATCH] Better error message on timeout. --- CHANGELOG.md | 3 +++ cmd/account/create/run.go | 15 ++++++++++----- cmd/account/derive/run.go | 15 ++++++++++----- cmd/account/import/run.go | 15 ++++++++++----- cmd/account/key/run.go | 15 ++++++++++----- cmd/attester/duties/run.go | 15 ++++++++++----- cmd/attester/inclusion/run.go | 15 ++++++++++----- cmd/block/analyze/run.go | 15 ++++++++++----- cmd/block/info/run.go | 15 ++++++++++----- cmd/chain/eth1votes/run.go | 15 ++++++++++----- cmd/chain/queues/run.go | 15 ++++++++++----- cmd/chain/time/run.go | 15 ++++++++++----- .../verify/signedcontributionandproof/run.go | 15 ++++++++++----- cmd/epoch/summary/run.go | 15 ++++++++++----- cmd/node/events/run.go | 13 +++++++++---- cmd/proposer/duties/run.go | 15 ++++++++++----- cmd/slot/time/run.go | 15 ++++++++++----- cmd/synccommittee/inclusion/run.go | 15 ++++++++++----- cmd/synccommittee/members/run.go | 15 ++++++++++----- cmd/validator/credentials/get/run.go | 15 ++++++++++----- cmd/validator/credentials/set/run.go | 15 ++++++++++----- cmd/validator/depositdata/run.go | 17 ++++++++++++----- cmd/validator/duties/run.go | 15 ++++++++++----- cmd/validator/exit/run.go | 15 ++++++++++----- cmd/validator/expectation/run.go | 15 ++++++++++----- cmd/validator/keycheck/run.go | 15 ++++++++++----- cmd/validator/summary/run.go | 15 ++++++++++----- cmd/validator/withdrawal/run.go | 15 ++++++++++----- cmd/validator/yield/run.go | 15 ++++++++++----- cmd/wallet/batch/run.go | 15 ++++++++++----- cmd/wallet/create/run.go | 15 ++++++++++----- cmd/wallet/delete/run.go | 15 ++++++++++----- cmd/wallet/export/run.go | 15 ++++++++++----- cmd/wallet/import/run.go | 15 ++++++++++----- cmd/wallet/sharedexport/run.go | 15 ++++++++++----- cmd/wallet/sharedimport/run.go | 15 ++++++++++----- 36 files changed, 354 insertions(+), 174 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9c75c1..06c322c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +dev: + - provide better error message on context deadlline exceeded + 1.35.2: - update dependencies diff --git a/cmd/account/create/run.go b/cmd/account/create/run.go index dc4da9a..e82fda5 100644 --- a/cmd/account/create/run.go +++ b/cmd/account/create/run.go @@ -1,4 +1,4 @@ -// Copyright © 2019, 2020 Weald Technology Trading +// Copyright © 2019 - 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package accountcreate import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if !viper.GetBool("verbose") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/account/derive/run.go b/cmd/account/derive/run.go index 255de55..21be25d 100644 --- a/cmd/account/derive/run.go +++ b/cmd/account/derive/run.go @@ -1,4 +1,4 @@ -// Copyright © 2020 Weald Technology Trading +// Copyright © 2020, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,9 +15,9 @@ package accountderive import ( "context" + "errors" "strings" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to obtain input"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if dataIn.quiet { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return strings.TrimSuffix(results, "\n"), nil diff --git a/cmd/account/import/run.go b/cmd/account/import/run.go index 7e8721d..1abf386 100644 --- a/cmd/account/import/run.go +++ b/cmd/account/import/run.go @@ -1,4 +1,4 @@ -// Copyright © 2019, 2020 Weald Technology Trading +// Copyright © 2019 - 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package accountimport import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to obtain input"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if !viper.GetBool("verbose") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/account/key/run.go b/cmd/account/key/run.go index 3fa1ce3..a0215b7 100644 --- a/cmd/account/key/run.go +++ b/cmd/account/key/run.go @@ -1,4 +1,4 @@ -// Copyright © 2019, 2020 Weald Technology Trading +// Copyright © 2019 - 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package accountkey import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/attester/duties/run.go b/cmd/attester/duties/run.go index af0db47..1f59fd7 100644 --- a/cmd/attester/duties/run.go +++ b/cmd/attester/duties/run.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Weald Technology Trading +// Copyright © 2021, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package attesterduties import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/attester/inclusion/run.go b/cmd/attester/inclusion/run.go index 77d5a1b..9e1fc8b 100644 --- a/cmd/attester/inclusion/run.go +++ b/cmd/attester/inclusion/run.go @@ -1,4 +1,4 @@ -// Copyright © 2019, 2020 Weald Technology Trading +// Copyright © 2019 - 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package attesterinclusion import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/block/analyze/run.go b/cmd/block/analyze/run.go index 3f91701..9c321c0 100644 --- a/cmd/block/analyze/run.go +++ b/cmd/block/analyze/run.go @@ -1,4 +1,4 @@ -// Copyright © 2022 Weald Technology Trading. +// Copyright © 2022, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package blockanalyze import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/block/info/run.go b/cmd/block/info/run.go index 256178a..fbfad40 100644 --- a/cmd/block/info/run.go +++ b/cmd/block/info/run.go @@ -1,4 +1,4 @@ -// Copyright © 2019, 2020 Weald Technology Trading +// Copyright © 2019 - 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package blockinfo import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/chain/eth1votes/run.go b/cmd/chain/eth1votes/run.go index 8290d71..c3874f7 100644 --- a/cmd/chain/eth1votes/run.go +++ b/cmd/chain/eth1votes/run.go @@ -1,4 +1,4 @@ -// Copyright © 2022 Weald Technology Trading. +// Copyright © 2022, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package chaineth1votes import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/chain/queues/run.go b/cmd/chain/queues/run.go index fa6e520..cd8e193 100644 --- a/cmd/chain/queues/run.go +++ b/cmd/chain/queues/run.go @@ -1,4 +1,4 @@ -// Copyright © 2022 Weald Technology Trading. +// Copyright © 2022, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package chainqueues import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/chain/time/run.go b/cmd/chain/time/run.go index 52e5310..c28bea1 100644 --- a/cmd/chain/time/run.go +++ b/cmd/chain/time/run.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Weald Technology Trading +// Copyright © 2021, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package chaintime import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/chain/verify/signedcontributionandproof/run.go b/cmd/chain/verify/signedcontributionandproof/run.go index d9ba34c..77c907b 100644 --- a/cmd/chain/verify/signedcontributionandproof/run.go +++ b/cmd/chain/verify/signedcontributionandproof/run.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Weald Technology Trading. +// Copyright © 2021, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package chainverifysignedcontributionandproof import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/epoch/summary/run.go b/cmd/epoch/summary/run.go index 00f8830..a9bd33e 100644 --- a/cmd/epoch/summary/run.go +++ b/cmd/epoch/summary/run.go @@ -1,4 +1,4 @@ -// Copyright © 2022 Weald Technology Trading. +// Copyright © 2022, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package epochsummary import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/node/events/run.go b/cmd/node/events/run.go index fa7472e..53974b2 100644 --- a/cmd/node/events/run.go +++ b/cmd/node/events/run.go @@ -1,4 +1,4 @@ -// Copyright © 2019, 2020 Weald Technology Trading +// Copyright © 2019 - 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package nodeevents import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -25,14 +25,19 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := process(ctx, dataIn); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } // Process generates all output. diff --git a/cmd/proposer/duties/run.go b/cmd/proposer/duties/run.go index 87e06e4..5453400 100644 --- a/cmd/proposer/duties/run.go +++ b/cmd/proposer/duties/run.go @@ -1,4 +1,4 @@ -// Copyright © 2022 Weald Technology Trading. +// Copyright © 2022, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package proposerduties import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/slot/time/run.go b/cmd/slot/time/run.go index e4cb99a..317cda7 100644 --- a/cmd/slot/time/run.go +++ b/cmd/slot/time/run.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Weald Technology Trading +// Copyright © 2021, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package slottime import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/synccommittee/inclusion/run.go b/cmd/synccommittee/inclusion/run.go index 29211d2..9fc94e3 100644 --- a/cmd/synccommittee/inclusion/run.go +++ b/cmd/synccommittee/inclusion/run.go @@ -1,4 +1,4 @@ -// Copyright © 2022 Weald Technology Trading. +// Copyright © 2022, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package inclusion import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/synccommittee/members/run.go b/cmd/synccommittee/members/run.go index 80bf685..249b174 100644 --- a/cmd/synccommittee/members/run.go +++ b/cmd/synccommittee/members/run.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Weald Technology Trading +// Copyright © 2021, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package members import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/validator/credentials/get/run.go b/cmd/validator/credentials/get/run.go index 06764a4..a454cf1 100644 --- a/cmd/validator/credentials/get/run.go +++ b/cmd/validator/credentials/get/run.go @@ -1,4 +1,4 @@ -// Copyright © 2022 Weald Technology Trading. +// Copyright © 2022, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package validatorcredentialsget import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/validator/credentials/set/run.go b/cmd/validator/credentials/set/run.go index 33417d2..1164e1e 100644 --- a/cmd/validator/credentials/set/run.go +++ b/cmd/validator/credentials/set/run.go @@ -1,4 +1,4 @@ -// Copyright © 2022 Weald Technology Trading. +// Copyright © 2022, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package validatorcredentialsset import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/validator/depositdata/run.go b/cmd/validator/depositdata/run.go index e850f73..d4b9854 100644 --- a/cmd/validator/depositdata/run.go +++ b/cmd/validator/depositdata/run.go @@ -1,4 +1,4 @@ -// Copyright © 2019, 2020 Weald Technology Trading +// Copyright © 2019 - 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -14,7 +14,9 @@ package depositdata import ( - "github.com/pkg/errors" + "context" + "errors" + "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -23,7 +25,7 @@ import ( func Run(cmd *cobra.Command) (string, error) { dataIn, err := input() if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -31,7 +33,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -40,7 +47,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/validator/duties/run.go b/cmd/validator/duties/run.go index 3ffc028..2d2a043 100644 --- a/cmd/validator/duties/run.go +++ b/cmd/validator/duties/run.go @@ -1,4 +1,4 @@ -// Copyright © 2019, 2020 Weald Technology Trading +// Copyright © 2019 - 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package validatorduties import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/validator/exit/run.go b/cmd/validator/exit/run.go index 0dec62a..9bf67cf 100644 --- a/cmd/validator/exit/run.go +++ b/cmd/validator/exit/run.go @@ -1,4 +1,4 @@ -// Copyright © 2023 Weald Technology Trading. +// Copyright © 2023, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package validatorexit import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/validator/expectation/run.go b/cmd/validator/expectation/run.go index a9635a6..7466c9f 100644 --- a/cmd/validator/expectation/run.go +++ b/cmd/validator/expectation/run.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Weald Technology Trading. +// Copyright © 2021, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package validatorexpectation import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/validator/keycheck/run.go b/cmd/validator/keycheck/run.go index f330814..af35573 100644 --- a/cmd/validator/keycheck/run.go +++ b/cmd/validator/keycheck/run.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Weald Technology Trading +// Copyright © 2021, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,10 +15,10 @@ package validatorkeycheck import ( "context" + "errors" "fmt" "os" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -27,7 +27,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -35,12 +35,17 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", err + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } results, exitCode, err := output(ctx, dataOut) if err != nil { - return "", err + return "", errors.Join(errors.New("failed to obtain output"), err) } if exitCode != 0 { fmt.Println(results) diff --git a/cmd/validator/summary/run.go b/cmd/validator/summary/run.go index d5f5d66..76bc1cd 100644 --- a/cmd/validator/summary/run.go +++ b/cmd/validator/summary/run.go @@ -1,4 +1,4 @@ -// Copyright © 2022 Weald Technology Trading. +// Copyright © 2022, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package validatorsummary import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/validator/withdrawal/run.go b/cmd/validator/withdrawal/run.go index 066923e..add7038 100644 --- a/cmd/validator/withdrawal/run.go +++ b/cmd/validator/withdrawal/run.go @@ -1,4 +1,4 @@ -// Copyright © 2023 Weald Technology Trading. +// Copyright © 2023, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package validatorwithdrawl import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/validator/yield/run.go b/cmd/validator/yield/run.go index 118847a..5fc00c5 100644 --- a/cmd/validator/yield/run.go +++ b/cmd/validator/yield/run.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Weald Technology Trading. +// Copyright © 2021, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package validatoryield import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/wallet/batch/run.go b/cmd/wallet/batch/run.go index 82b3e2a..fdeefb2 100644 --- a/cmd/wallet/batch/run.go +++ b/cmd/wallet/batch/run.go @@ -1,4 +1,4 @@ -// Copyright © 2023 Weald Technology Trading. +// Copyright © 2023, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package walletbatch import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,14 +27,19 @@ func Run(cmd *cobra.Command) (string, error) { c, err := newCommand(ctx) if err != nil { - return "", errors.Wrap(err, "failed to set up command") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. cmd.SilenceUsage = true if err := c.process(ctx); err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := c.output(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/wallet/create/run.go b/cmd/wallet/create/run.go index 45cb284..946fa5c 100644 --- a/cmd/wallet/create/run.go +++ b/cmd/wallet/create/run.go @@ -1,4 +1,4 @@ -// Copyright © 2019, 2020 Weald Technology Trading +// Copyright © 2019 - 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package walletcreate import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/wallet/delete/run.go b/cmd/wallet/delete/run.go index 3a845b0..0206fa3 100644 --- a/cmd/wallet/delete/run.go +++ b/cmd/wallet/delete/run.go @@ -1,4 +1,4 @@ -// Copyright © 2019, 2020 Weald Technology Trading +// Copyright © 2019 - 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package walletdelete import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if !viper.GetBool("verbose") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/wallet/export/run.go b/cmd/wallet/export/run.go index a27d164..f2b9e29 100644 --- a/cmd/wallet/export/run.go +++ b/cmd/wallet/export/run.go @@ -1,4 +1,4 @@ -// Copyright © 2019, 2020 Weald Technology Trading +// Copyright © 2019 - 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package walletexport import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/wallet/import/run.go b/cmd/wallet/import/run.go index 0fdbd2e..fd5f5f4 100644 --- a/cmd/wallet/import/run.go +++ b/cmd/wallet/import/run.go @@ -1,4 +1,4 @@ -// Copyright © 2019, 2020 Weald Technology Trading +// Copyright © 2019 - 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package walletimport import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/wallet/sharedexport/run.go b/cmd/wallet/sharedexport/run.go index 39befa8..a36de52 100644 --- a/cmd/wallet/sharedexport/run.go +++ b/cmd/wallet/sharedexport/run.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Weald Technology Trading +// Copyright © 2021, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package walletsharedexport import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil diff --git a/cmd/wallet/sharedimport/run.go b/cmd/wallet/sharedimport/run.go index 219ad19..4b11981 100644 --- a/cmd/wallet/sharedimport/run.go +++ b/cmd/wallet/sharedimport/run.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Weald Technology Trading +// Copyright © 2021, 2024 Weald Technology Trading. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,8 +15,8 @@ package walletsharedimport import ( "context" + "errors" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -26,7 +26,7 @@ func Run(cmd *cobra.Command) (string, error) { ctx := context.Background() dataIn, err := input(ctx) if err != nil { - return "", errors.Wrap(err, "failed to obtain input") + return "", errors.Join(errors.New("failed to set up command"), err) } // Further errors do not need a usage report. @@ -34,7 +34,12 @@ func Run(cmd *cobra.Command) (string, error) { dataOut, err := process(ctx, dataIn) if err != nil { - return "", errors.Wrap(err, "failed to process") + switch { + case errors.Is(err, context.DeadlineExceeded): + return "", errors.New("operation timed out; try increasing with --timeout option") + default: + return "", errors.Join(errors.New("failed to process"), err) + } } if viper.GetBool("quiet") { @@ -43,7 +48,7 @@ func Run(cmd *cobra.Command) (string, error) { results, err := output(ctx, dataOut) if err != nil { - return "", errors.Wrap(err, "failed to obtain output") + return "", errors.Join(errors.New("failed to obtain output"), err) } return results, nil