-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters