-
Notifications
You must be signed in to change notification settings - Fork 19
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
go: Fix more linter problems #228
Conversation
reader.Seek(txIndex - 1) | ||
if err != nil { | ||
return lcm, ingest.LedgerTransaction{}, | ||
errors.Wrapf(err, "failed to index to tx %d in ledger %d (txhash=%s)", | ||
txIndex, lcm.LedgerSequence(), hash) | ||
fmt.Errorf("failed to create ledger reader: %w", err) | ||
} | ||
err = reader.Seek(txIndex - 1) | ||
if err != nil { | ||
return lcm, ingest.LedgerTransaction{}, | ||
fmt.Errorf("failed to index to tx %d in ledger %d (txhash=%s): %w", | ||
txIndex, lcm.LedgerSequence(), hash, 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.
This one was ugly (the seek error wasn't checked)
7e25e20
to
32bc2e5
Compare
78c719e
to
f66c6d2
Compare
f66c6d2
to
d1e9fe3
Compare
@@ -239,7 +243,7 @@ func TestGetTransactions_LedgerNotFound(t *testing.T) { | |||
} | |||
|
|||
response, err := handler.getTransactionsByLedgerSequence(context.TODO(), request) | |||
expectedErr := errors.Errorf("[%d] ledger close meta not found: 2", jrpc2.InvalidParams) | |||
expectedErr := fmt.Errorf("[%d] ledger close meta not found: 2", jrpc2.InvalidParams) |
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.
Why moving from errors package to fmt?
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.
Because our internal errors package uses an outdated implementation of error wrapping https://github.com/pkg/errors (which only made sense when the std library didn't implement it)
The std library now provides "errors"
and fmt.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.
We should remove the package from stellar/go
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.
Looks good !!
I broke it at stellar#228 It turns out that `github.com/stellar/go/support/errors.Wrapf` returns nil if the error is nil (which is different to how `errors.Errorf` behaves). I have looked at both stellar#228 and stellar#224 and this is the only instance in which we replaced `Wrapf` by `Errorf` where we don't first check the error for `nil`.
I broke it at stellar#228 It turns out that `github.com/stellar/go/support/errors.Wrapf` returns nil if the error is nil (which is different to how `errors.Errorf` behaves). I have looked at both stellar#228 and stellar#224 and this is the only instance in which we replaced `Wrapf` by `Errorf` where we don't first check the error for `nil`.
I broke it at #228 It turns out that `github.com/stellar/go/support/errors.Wrapf` returns nil if the error is nil (which is different to how `errors.Errorf` behaves). I have looked at both #228 and #224 and this is the only instance in which we replaced `Wrapf` by `Errorf` where we don't first check the error for `nil`.
No description provided.