-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat: replace deprecated logger methods #546
base: main
Are you sure you want to change the base?
Conversation
35c8edb
to
8214cc0
Compare
Signed-off-by: Evsyukov Denis <[email protected]>
8214cc0
to
0881a1f
Compare
if hookResult == nil { | ||
return nil | ||
} | ||
|
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.
What for? As I see, we only return nil when there is an error in the Execute() call
And even if we get nil, shouldn't we return err then?
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.
A rather strange logic is used here,
- We calculate the result
hookResult, err := h.Execute(h.GetConfigVersion(), bc, "global", prefixedConfigValues, prefixedValues, logLabels)
- Next, we check that the result is not null and there is a Usage to display the result.
- Only after that we check for the error, and if there is one, return it.
- And after that, we are already trying to fully access the hookResult fields, although theoretically it is possible that we get nil. As a result, instead of a mistake, we will get panic.
- To avoid panic, we do a check on nil before accessing the hookResult fields. Since we've already checked for errors and they're no longer there, since we've got a hookResult with nil, we'll just exit the function with the result nil.
In a good way, after the calculation, you need to immediately check the error, if there is one, return it. Then check for nil, and then decide what to do, return a new error or return nil. And then process the result.
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.
yeah, the logic is strange, or even tightly coupled with what h.Execute() returns, but if there is no possibility of getting nil without errors, does it make sense to check? :)
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.
and if we check and get nil for the result, but w/o an error, it looks to me like an error condition 🤔 . I think we'd better return a custom error like 'something went wrong' instead of concealing the fact that we'd got nothing.
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.
It makes sense to think about it
Overview
Fixed: #524
What this PR does / why we need it
Just replace deprecated logger methods
Special notes for your reviewer
nope