From ecb1b1514e0dad630731c2d2d0d05102f6afdb98 Mon Sep 17 00:00:00 2001 From: Dongri Jin Date: Wed, 6 Sep 2023 12:46:34 +0900 Subject: [PATCH 1/3] Add return err Signed-off-by: Dongri Jin --- cmd/chains.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/chains.go b/cmd/chains.go index d4f6516e..c30662c6 100644 --- a/cmd/chains.go +++ b/cmd/chains.go @@ -59,19 +59,19 @@ func filesAdd(ctx *config.Context, dir string) error { byt, err := os.ReadFile(pth) if err != nil { fmt.Printf("failed to read file %s, skipping...\n", pth) - continue + return err } var c core.ChainProverConfig if err := json.Unmarshal(byt, &c); err != nil { fmt.Printf("failed to unmarshal file %s, skipping...\n", pth) - continue + return err } if err := c.Init(ctx.Codec); err != nil { return err } if err = ctx.Config.AddChain(ctx.Codec, c); err != nil { fmt.Printf("%s: %s\n", pth, err.Error()) - continue + return err } chain, err := c.Build() if err != nil { From 21850879ea0f2ffc0d019cf16f7bec34305c0b5f Mon Sep 17 00:00:00 2001 From: Dongri Jin Date: Thu, 7 Sep 2023 09:14:28 +0900 Subject: [PATCH 2/3] Fix return err Signed-off-by: Dongri Jin --- cmd/chains.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/chains.go b/cmd/chains.go index c30662c6..a243e2e1 100644 --- a/cmd/chains.go +++ b/cmd/chains.go @@ -58,20 +58,17 @@ func filesAdd(ctx *config.Context, dir string) error { } byt, err := os.ReadFile(pth) if err != nil { - fmt.Printf("failed to read file %s, skipping...\n", pth) - return err + return fmt.Errorf("failed to read file %s, error: %v", pth, err) } var c core.ChainProverConfig if err := json.Unmarshal(byt, &c); err != nil { - fmt.Printf("failed to unmarshal file %s, skipping...\n", pth) - return err + return fmt.Errorf("failed to unmarshal file %s, error: %v", pth, err) } if err := c.Init(ctx.Codec); err != nil { return err } if err = ctx.Config.AddChain(ctx.Codec, c); err != nil { - fmt.Printf("%s: %s\n", pth, err.Error()) - return err + return fmt.Errorf("failed add chain %s, error: %v", pth, err) } chain, err := c.Build() if err != nil { From e4c140f59be72296ec2b408165ea317e0746d573 Mon Sep 17 00:00:00 2001 From: Dongri Jin Date: Thu, 7 Sep 2023 13:00:08 +0900 Subject: [PATCH 3/3] Fix error message Signed-off-by: Dongri Jin --- cmd/chains.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/chains.go b/cmd/chains.go index a243e2e1..3e75d1f2 100644 --- a/cmd/chains.go +++ b/cmd/chains.go @@ -65,10 +65,10 @@ func filesAdd(ctx *config.Context, dir string) error { return fmt.Errorf("failed to unmarshal file %s, error: %v", pth, err) } if err := c.Init(ctx.Codec); err != nil { - return err + return fmt.Errorf("failed to init chain %s, error: %v", pth, err) } if err = ctx.Config.AddChain(ctx.Codec, c); err != nil { - return fmt.Errorf("failed add chain %s, error: %v", pth, err) + return fmt.Errorf("failed to add chain %s, error: %v", pth, err) } chain, err := c.Build() if err != nil {