Skip to content

Commit

Permalink
fix: use status as error message
Browse files Browse the repository at this point in the history
  • Loading branch information
PhearZero committed Oct 29, 2024
1 parent 65c16a2 commit 6deb00d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions internal/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6deb00d

Please sign in to comment.