Skip to content

Conversation

@chatton
Copy link
Contributor

@chatton chatton commented Aug 25, 2020

All Submissions:

  • Have you signed our CLA?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

This PR updates the codebase to use pkg/errors.Errorf in place of fmt.Errorf
the format strings have been updated to use %s (the intended mechanism for handling errors in format strings)

@chatton chatton requested a review from bznein August 25, 2020 15:20
Copy link
Contributor

@bznein bznein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but unless I misunderstood something we can achieve even more consistency in our error handling

Password: password,
})); err != nil {
t.Fatal(fmt.Sprintf("Error connecting to MongoDB deployment: %+v", err))
t.Fatal(fmt.Sprintf("Error connecting to MongoDB deployment: %s", err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] is there a specific reason here we use fmt.Sprintf? A few lines below we have the same structure (t.Fatal) with inside a errors.Errorf

case <-time.After(interval):
if err := connectFunc(); err != nil {
t.Fatal(fmt.Sprintf("error reaching MongoDB deployment: %+v", err))
t.Fatal(fmt.Sprintf("error reaching MongoDB deployment: %s", err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the previous comment


if err := setup.CreateTLSResources(mdb.Namespace, ctx); err != nil {
t.Fatalf("Failed to set up TLS resources: %+v", err)
t.Fatalf("Failed to set up TLS resources: %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing this and referring to my other two comments, maybe using t.Fatalf every time would be better? I feel we have a mixture of three different approaches at the moment:

t.Fatalf
t.Fatal(fmt.Sprintf(...))
t.Fatal(errors.Errorf(...))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I agree! I will update to use one. I think t.Fatalf is the most straightfoward, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so! No need to nest function calls!

@chatton chatton merged commit ab14dc5 into master Aug 25, 2020
@chatton chatton deleted the ensure_consistent_errors branch August 25, 2020 16:37
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.

3 participants