rotisserie/eris

eris.As is incompatible with eris.Wrap

aarondl0 opened this issue · 2 comments

Describe the bug
eris.As does not work as intended when wrapping with eris.Wrap()

To Reproduce
Run this program:

package main

import (
	"errors"
	"fmt"

	"github.com/rotisserie/eris"
)

type X struct {
}

func (X) Error() string {
	return "X"
}

func main() {
	original := X{}

	wrap1std := fmt.Errorf("wrap1: %w", original)
	wrap2std := fmt.Errorf("wrap2: %w", wrap1std)

	wrap1eris := eris.Wrap(original, "wrap1")
	wrap2eris := eris.Wrap(wrap1eris, "wrap2")

	var x X
	fmt.Println(errors.As(wrap2std, &x))
	fmt.Println(errors.As(wrap2eris, &x))

	fmt.Println(eris.As(wrap2std, &x))
	fmt.Println(eris.As(wrap2eris, &x))
}

Expected behavior
The program should output true 4 times. Instead it outputs:

true
true
true
false

Go: 1.16.5
Eris: github.com/rotisserie/eris@v0.5.0

hey @aarondl0, thanks for the bug report! i’ll take a closer look at it asap.

hey @aarondl0, i just merged a fix for this and released v0.5.1. thanks again for the bug report and let me know if you're still having issues with it!