-
Notifications
You must be signed in to change notification settings - Fork 9
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
fix: add checks on ResultBroadcastTx
to avoid NPE + cleanup error handling code
#18
Conversation
// Log the error | ||
logger.Error(fmt.Sprintf("error during broadcast: %s", getErrorString(err, rpcResponse))) | ||
|
||
if err != nil || rpcResponse == 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.
Since this is nested in the previous "if" statement, is this if err != ni
necessary?
@@ -66,7 +67,7 @@ func StartListener(cfg config.Config, logger log.Logger, processingQueue chan *t | |||
for _, historicalLog := range history { | |||
parsedMsg, err := types.EvmLogToMessageState(messageTransmitterABI, messageSent, &historicalLog) | |||
if err != nil { | |||
logger.Error("Unable to parse history log into MessageState, skipping") | |||
logger.Error("Unable to parse history log into MessageState, skipping", "err", 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.
Nice. I had the same idea in order to help with issues like #9.
I think this PR could close out that issue too.
Also, we should merge into |
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
This PR adds an additional check on
ResultBroadcastTx
, which is returned byBroadcastTxSync
, to ensure the result is not nil before attempting to log the response code and logs.This also cleans up the error handling code to remove duplicate code and separates concerns into smaller functions for better readability and maintainability.
Closes #17