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

Use error wrapping to test without string comparison. #1451

Merged
merged 1 commit into from
Jan 15, 2020

Conversation

absoludity
Copy link
Contributor

@absoludity absoludity commented Jan 14, 2020

Description of the change

In #1445 I removed some detail from an error because I couldn't figure out a good way to test the situation (without resorting to string comparisons). I had tried to use the new error wrapping ability, but since the underlying error (from ptypes.timestamp) doesn't return or expose a standard error, I was unable to use errors.Is() to identify it.

With a fresh mind this morning, I realised that fmt.Errorf intentionally allows you to wrap either error while still maintaining the same error string in the result. That allows this simple change to work. See what you think

Benefits

Allows handling errors and identifying our own errors using errors.Is as is done here in a test (but not restricted to tests).

Additional information

This is an alternative to #1447

@absoludity absoludity requested a review from andresmgot January 14, 2020 23:42
@absoludity absoludity changed the title User error wrapping to test without string comparison. Use error wrapping to test without string comparison. Jan 14, 2020
Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@andresmgot andresmgot merged commit d4eba1a into vmware-tanzu:master Jan 15, 2020
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

Successfully merging this pull request may close these issues.

2 participants