Skip to content

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

Description

@bivas

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))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions