-
Notifications
You must be signed in to change notification settings - Fork 521
Ensure consistent errors #147
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
Conversation
bznein
left a comment
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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(...))
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
All Submissions:
This PR updates the codebase to use
pkg/errors.Errorfin place offmt.Errorfthe format strings have been updated to use
%s(the intended mechanism for handling errors in format strings)