tracerr icon indicating copy to clipboard operation
tracerr copied to clipboard

Supporting Go 1.13+ wrapped errors

Open wttw opened this issue 5 years ago • 0 comments

Go 1.13 supports wrapping errors in a standard way.

tracerr doesn't print stack traces of wrapped errors, as it doesn't know how to look inside to see the wrapped error is a tracerr.Error.

Changing the test in print.go from

        e, ok := err.(Error)
	if !ok {
		return err.Error()
	}

to

        var e Error
	if !errors.As(err, &e) {
		return err.Error()
	}

It's a fairly trivial change, but does mean that it won't compile with Go 1.12 or earlier, without some minor refactoring and build flags.

wttw avatar Sep 11 '20 09:09 wttw