Closed Zamiell closed 4 years ago
Is this a bug in the linter or am I misunderstanding the error message?
Actually, neither
the main idea behind this linter was to force people (mostly the people I'm working with) to build an errors hierarchy.
I would modify your code this way:
var ErrNotEqual = errors.New("not equal")
func testingSubroutine(i1 int, i2 int) error {
if i1 != i2 {
return fmt.Errorf("i1 and i2: %w", ErrNotEqual)
}
return nil
}
As a result, we can pass the equal info in the error and at the same time the error is analysable: you can check is it non-equal error with errors.Is(err, ErrNotEqual)
Excellent, thank you.
Greetings and thanks for the linter.
The linter doesn't seem to like the following code:
It gives the error:
However, this seems nonsensical, because there is nothing to wrap. I'm just creating a brand new error. Is this a bug in the linter or am I misunderstanding the error message?