implement Exception.Unwrap method #1174
x.yml
on: pull_request
commit
/
lint
18s
lint
/
run
33s
lint
/
mod
14s
lint
/
gen
30s
Matrix: test / run
Annotations
4 errors
commit / lint
You have commit messages with errors
⧗ input: implement Exception.Unwrap method
In order to make exceptions testable with errors.Is, they must implement
the `Unwrap` method to allow access to the underlying error code(s).
This change is addressing the problem of the below code not working as
expected, when testing returned by `Do` method error:
c, _ := ch.Dial(ctx, ch.Options{...})
switch err := c.Do(ctx, ch.Query{...}); {
case err == nil:
// ...
case errors.Is(err, proto.ErrTableIsReadOnly), errors.Is(err, proto.ErrReadonly):
// ... <- Never executed, because exception unwraping is not implemented.
default:
// ...
}
Because `Exception` instances are created dynamically, unwrapping can
ignore nested exception instances and collect only the underlying error
codes.
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]
✖ found 2 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
|
lint / run:
client.go#L150
G601: Implicit memory aliasing in for loop. (gosec)
|
lint / run:
client_test.go#L116
unnecessary trailing newline (whitespace)
|
lint / run
issues found
|