-
Notifications
You must be signed in to change notification settings - Fork 38
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
Return error instead of just logging it if client fails #1632
Conversation
WalkthroughThe changes primarily focus on enhancing error handling in the Changes
TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (2)
- tools/walletextension/accountmanager/account_manager.go (1 hunks)
- tools/walletextension/wallet_extension.go (1 hunks)
Files skipped from review due to trivial changes (1)
- tools/walletextension/accountmanager/account_manager.go
encClient, err := common.CreateEncClient(w.hostAddr, addressFromMessage.Bytes(), privateKeyBytes, signature, w.Logger()) | ||
if err != nil { | ||
w.Logger().Error(fmt.Errorf("error creating encrypted client for user: (%s), %w", hexUserID, err).Error()) | ||
return errors.New(fmt.Errorf("error creating encrypted client for user: (%s), %w", hexUserID, err).Error()) | ||
} |
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.
The error message is being wrapped twice, which is unnecessary. The error returned from common.CreateEncClient
should be returned directly after logging it.
- w.Logger().Error(fmt.Errorf("error creating encrypted client for user: (%s), %w", hexUserID, err).Error())
- return errors.New(fmt.Errorf("error creating encrypted client for user: (%s), %w", hexUserID, err).Error())
+ w.Logger().Error(fmt.Sprintf("error creating encrypted client for user: (%s), %v", hexUserID, err))
+ return err
Commitable suggestion (Beta)
encClient, err := common.CreateEncClient(w.hostAddr, addressFromMessage.Bytes(), privateKeyBytes, signature, w.Logger()) | |
if err != nil { | |
w.Logger().Error(fmt.Errorf("error creating encrypted client for user: (%s), %w", hexUserID, err).Error()) | |
return errors.New(fmt.Errorf("error creating encrypted client for user: (%s), %w", hexUserID, err).Error()) | |
} | |
encClient, err := common.CreateEncClient(w.hostAddr, addressFromMessage.Bytes(), privateKeyBytes, signature, w.Logger()) | |
if err != nil { | |
w.Logger().Error(fmt.Sprintf("error creating encrypted client for user: (%s), %v", hexUserID, err)) | |
return 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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- tools/walletextension/accountmanager/account_manager.go (1 hunks)
- tools/walletextension/wallet_extension.go (1 hunks)
Files skipped from review due to trivial changes (1)
- tools/walletextension/accountmanager/account_manager.go
Additional comments: 1
tools/walletextension/wallet_extension.go (1)
- 249-255: The error handling and logging are correctly implemented. The function now returns an error if there's an issue creating an encrypted client, allowing the caller to handle the error appropriately. This is a good practice for error management and system reliability.
Why this change is needed
Please provide a description and a link to the underlying ticket
What changes were made as part of this PR
Please provide a high level list of the changes made
PR checks pre-merging
Please indicate below by ticking the checkbox that you have read and performed the required
PR checks