From fac286fc9108106d46f464f0b6d8fd6ca2a33add Mon Sep 17 00:00:00 2001 From: Dmytro Vovk Date: Sat, 21 Sep 2024 17:02:18 +0100 Subject: [PATCH] updated errors messages (#93) --- internal/erigon_node/profile.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/erigon_node/profile.go b/internal/erigon_node/profile.go index 60ecbea..4fa9706 100644 --- a/internal/erigon_node/profile.go +++ b/internal/erigon_node/profile.go @@ -16,25 +16,25 @@ func (c *NodeClient) FindProfile(ctx context.Context, profile string) ([]byte, e request, err := c.fetch(ctx, profile, nil) if err != nil { - return nil, err + return nil, fmt.Errorf("Error fetching profile: %v", err) } _, result, err := request.nextResult(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("Error fetching profile content: %v", err) } var content ProfileContent if err := json.Unmarshal(result, &content); err != nil { - return nil, err + return nil, fmt.Errorf("Error unmarshalling profile content: %v", err) } //result is a file content so I need to save it to file and return the file path tempFile, err := os.CreateTemp("", "profile-*.pprof") if err != nil { - return nil, err + return nil, fmt.Errorf("Error creating temporary file: %v", err) } defer func() { @@ -49,13 +49,13 @@ func (c *NodeClient) FindProfile(ctx context.Context, profile string) ([]byte, e }() if _, err := tempFile.Write(content.Chunk); err != nil { - return nil, err + return nil, fmt.Errorf("Error writing to temporary file: %v", err) } cmd := exec.Command("go", "tool", "pprof", "-png", tempFile.Name()) svgOutput, err := cmd.Output() if err != nil { - return nil, err + return nil, fmt.Errorf("Error generating SVG output: %v", err) } return svgOutput, nil