Skip to content
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

Method should never return explicit error type (only error interface) #468

Open
liran-funaro opened this issue Nov 24, 2022 · 0 comments
Open

Comments

@liran-funaro
Copy link
Contributor

Assigning explicit error type (e.g., *ierrors.NotLeaderError) to an interface variable (e.g. var err error) will result in nil check to return false even if we assign a nil to it.
See https://go.dev/doc/faq#nil_error and https://go.dev/play/p/8HUKlSDPvCT

The following needs to change in bcdb/db.go:

DB

type DB interface {
	IsLeader() *ierrors.NotLeaderError
}

should be

type DB interface {
	IsLeader() error
}

TxProcessor

type TxProcessor interface {
	IsLeader() *ierrors.NotLeaderError
}

should be

type TxProcessor interface {
	IsLeader() error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant