From 9ebb8ada13b4493fa5f5cf86846003f2e6ee0f9a Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 16 Sep 2022 01:53:23 +0800 Subject: [PATCH] optimizer: wrap error with the output if err is not nil --- pkg/optimizer/local.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/optimizer/local.go b/pkg/optimizer/local.go index 4c3a51787..799bc9f5e 100644 --- a/pkg/optimizer/local.go +++ b/pkg/optimizer/local.go @@ -12,6 +12,7 @@ import ( "sync" "github.com/cheggaaa/pb/v3" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "gopkg.in/yaml.v3" @@ -81,15 +82,19 @@ func (e *LocalProcessExecutor) readReport(reportPath string) (*backtest.SummaryR // Prepare prepares the environment for the following back tests // this is a blocking operation func (e *LocalProcessExecutor) Prepare(configJson []byte) error { - log.Debugln("Sync database before launching backtests...") + log.Debugln("syncing backtest data before starting backtests...") tf, err := jsonToYamlConfig(e.ConfigDir, configJson) if err != nil { return err } c := exec.Command(e.Bin, "backtest", "--sync", "--sync-only", "--config", tf.Name()) - _, err = c.Output() - return err + output, err := c.Output() + if err != nil { + return errors.Wrapf(err, "failed to sync backtest data: %s", string(output)) + } + + return nil } func (e *LocalProcessExecutor) Run(ctx context.Context, taskC chan BacktestTask, bar *pb.ProgressBar) (chan BacktestTask, error) {