-
Notifications
You must be signed in to change notification settings - Fork 621
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
chore: use errors.New to replace fmt.Errorf with no parameters #8873
Conversation
Signed-off-by: ChengenH <[email protected]>
WalkthroughThe pull request introduces significant updates to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
x/gamm/pool-models/balancer/pool.go (1)
Line range hint
1-1000
: Consider using error constants for better maintainability.While the error message changes are good, consider defining these common error messages as constants at the package level, similar to the existing constants in the file. This would improve maintainability and reusability.
const ( + ErrZeroOrNegativeBalance = "can't add the zero or negative balance of token" + ErrDuplicatePoolAsset = "same PoolAsset already exists" + ErrInvalidPoolBalance = "can't set the pool's balance of a token to be zero or negative" // ... existing constants ... ) // Then use these constants in the code: -return errors.New("can't add the zero or negative balance of token") +return errors.New(ErrZeroOrNegativeBalance)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (8)
CONTRIBUTING.md
(1 hunks)x/gamm/client/cli/tx.go
(2 hunks)x/gamm/keeper/migrate.go
(2 hunks)x/gamm/keeper/pool.go
(2 hunks)x/gamm/pool-models/balancer/pool.go
(3 hunks)x/gamm/pool-models/balancer/pool_asset.go
(2 hunks)x/gamm/simulation/sim_msgs.go
(1 hunks)x/gamm/types/gov.go
(5 hunks)
🔇 Additional comments (12)
x/gamm/pool-models/balancer/pool_asset.go (1)
26-26
: LGTM! Appropriate use of errors.New
The change from fmt.Errorf
to errors.New
is correct here since the error message is static with no parameters.
x/gamm/types/gov.go (2)
68-68
: LGTM! Consistent error handling for empty records
Both instances correctly use errors.New
for the static error message "empty proposal records".
Also applies to: 120-120
Line range hint 178-199
: LGTM! Appropriate mix of error handling approaches
The changes correctly:
- Use
errors.New
for static messages (tick spacing, denom comparison, spread factor, pool ID) - Retain
fmt.Errorf
where parameter formatting is needed (denom validation errors)
x/gamm/keeper/pool.go (1)
263-263
: LGTM! Appropriate use of errors.New in panic message
The change from fmt.Errorf
to errors.New
is correct here since the panic message is static with no parameters.
x/gamm/keeper/migrate.go (1)
52-52
: LGTM: Appropriate use of errors.New
The change from fmt.Errorf to errors.New is correct here as the error message is a static string with no parameters.
x/gamm/simulation/sim_msgs.go (1)
99-99
: LGTM: Appropriate use of errors.New
The change from fmt.Errorf to errors.New is correct here as the error message is a static string with no parameters.
x/gamm/client/cli/tx.go (2)
530-530
: LGTM: Appropriate use of errors.New
The change from fmt.Errorf to errors.New is correct here as the error message is a static string with no parameters.
820-820
: LGTM: Appropriate use of errors.New
The change from fmt.Errorf to errors.New is correct here as the error message is a static string with no parameters.
CONTRIBUTING.md (1)
245-245
: LGTM: Error message format change is consistent with the PR objective.
The change from using fmt.Errorf
to errors.New
with a pre-formatted error message aligns with the PR's goal of standardizing error handling.
x/gamm/pool-models/balancer/pool.go (3)
144-144
: LGTM: Consistent error handling for token balance validation.
The change from fmt.Errorf
to errors.New
maintains the same error message while standardizing the error creation pattern.
153-153
: LGTM: Consistent error handling for duplicate pool assets.
The change from fmt.Errorf
to errors.New
maintains the same error message while standardizing the error creation pattern.
304-304
: LGTM: Consistent error handling for pool asset balance updates.
The change from fmt.Errorf
to errors.New
maintains the same error message while standardizing the error creation pattern.
Signed-off-by: ChengenH <[email protected]>
|
No description provided.