From 6deb00d5b4edff9c8a7bca9afee0719db5432f39 Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Tue, 29 Oct 2024 15:33:18 -0400 Subject: [PATCH] fix: use status as error message --- internal/block.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/block.go b/internal/block.go index e9701ee2..7f839a4e 100644 --- a/internal/block.go +++ b/internal/block.go @@ -18,7 +18,7 @@ func GetBlock(ctx context.Context, client *api.ClientWithResponses, round uint64 } if block.StatusCode() != 200 { - return nil, errors.New("invalid status code") + return nil, errors.New(block.Status()) } return block.JSON200.Block, nil @@ -45,17 +45,18 @@ func GetBlockMetrics(ctx context.Context, client *api.ClientWithResponses, round return nil, err } if a.StatusCode() != 200 { - return nil, errors.New("invalid status code") + return nil, errors.New(a.Status()) } b, err := client.GetBlockWithResponse(ctx, int(round)-window, &api.GetBlockParams{ Format: &format, }) - if a.StatusCode() != 200 { - return nil, errors.New("invalid status code") - } if err != nil { return nil, err } + if b.StatusCode() != 200 { + return nil, errors.New(b.Status()) + } + // Push to the transactions count list aTimestamp := time.Duration(a.JSON200.Block["ts"].(float64)) * time.Second bTimestamp := time.Duration(b.JSON200.Block["ts"].(float64)) * time.Second