Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated errors messages #93

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions internal/erigon_node/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down
Loading