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

errors.Errorf doesn't support %w format #4

Open
bivas opened this issue Dec 1, 2019 · 0 comments
Open

errors.Errorf doesn't support %w format #4

bivas opened this issue Dec 1, 2019 · 0 comments

Comments

@bivas
Copy link

bivas commented Dec 1, 2019

Issue I noticed is when trying errors.Errorf("reached 0 %w", Fail): This is actually doesn't support Go 1.13 error wrapping format (output was reached 0 %!w(*failure.FailError=&{}))

Created the following snippet to test it:

var (
	Fail = &FailError{}
)

type FailError struct{}

func (f FailError) Error() string {
	return "This is a fail error"
}

func FailR(depth int) error {
	if depth == 0 {
		return errors.Errorf("reached 0 %w", Fail) // This works fine: fmt.Errorf("reached 0 %w", Fail)
	}
	return errors.Wrap(FailR(depth-1), fmt.Sprintf("Failed stack (%d)", depth))
}
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

No branches or pull requests

1 participant