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

refactor ReadReadme func #62

Merged
merged 4 commits into from
Jul 2, 2024
Merged

refactor ReadReadme func #62

merged 4 commits into from
Jul 2, 2024

Conversation

theredditbandit
Copy link
Owner

No description provided.

@theredditbandit theredditbandit merged commit 00bd6f6 into master Jul 2, 2024
4 checks passed
@ccoVeille
Copy link
Contributor

It's worth trying to refactor this

-return nil, errors.Join(ErrReadREADME, fmt.Errorf("something went wrong while reading README for %s: %w", projectName, err))
+return nil, fmt.Errorf("something went wrong while reading README %w for %s: %w", ErrReadREADME, projectName, err)

@theredditbandit
Copy link
Owner Author

It's worth trying to refactor this

-return nil, errors.Join(ErrReadREADME, fmt.Errorf("something went wrong while reading README for %s: %w", projectName, err))
+return nil, fmt.Errorf("something went wrong while reading README %w for %s: %w", ErrReadREADME, projectName, err)

could you elaborate on this , I'm not sure how to go about refactoring this or rather what is wrong with this piece and what I should be aiming for.

@ccoVeille
Copy link
Contributor

could you elaborate on this , I'm not sure how to go about refactoring this or rather what is wrong with this piece and what I should be aiming for.

https://stackoverflow.com/questions/33470649/how-do-we-combine-multiple-error-strings-in-golang

I would find simple to read, but it's true that might be opinionated.

I looked for documentation and you might be right, when adding no wrapping information, using errors.Join might be a good way.

https://www.tiredsg.dev/blog/wrapping-multiple-errors-golang/

I would say that if you

It's just that for me, as you were already using fmt.Errorf("%w"), adding a second %w would have make more sense.

I hope it's clearer. But, feel free to ignore my idea.

@theredditbandit
Copy link
Owner Author

Thanks for the clear explanation, this makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants