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

Errors are not wrapped with %w #123

Open
marc-harrison opened this issue Apr 9, 2024 · 2 comments
Open

Errors are not wrapped with %w #123

marc-harrison opened this issue Apr 9, 2024 · 2 comments

Comments

@marc-harrison
Copy link

Errors like:

return Flags{}, &FlagsmithAPIError{msg: fmt.Sprintf("flagsmith: error performing request to Flagsmith API: %s", err)}

Are not wrapped with %w e.g.

return Flags{}, &FlagsmithAPIError{msg: fmt.Sprintf("flagsmith: error performing request to Flagsmith API: %w", err)}

This makes handling errors like -

  Failed to fetch flags with error:
    flagsmith:
      error performing request to Flagsmith API:
        Post "https://api.flagsmith.com/api/v1/identities/":
          context deadline exceeded (Client.Timeout exceeded while awaiting headers)

a challenge. I'm happy to make a PR there's 5 places.

@gagantrivedi
Copy link
Member

@marc-harrison Yep, a PR would be great!

@gagantrivedi
Copy link
Member

gagantrivedi commented Apr 10, 2024

Thinking about this a bit more: simply replacing %v with %w will not work because the error struct expects a string for msg field and not error.

What we do need to do is basically rewrite the whole error handling here, but that will mean a major version change

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

No branches or pull requests

2 participants