implement Exception.Unwrap method #126
Annotations
1 error
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
|