Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Intelligent errors.Cause() #143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

jaekwon
Copy link

@jaekwon jaekwon commented Dec 21, 2017

When causer.Cause() returns nil or itself, it is the cause.

Ref: #89

When causer.Cause() returns nil or itself, it is the cause.
@davecheney
Copy link
Member

davecheney commented Dec 21, 2017 via email

@jjeffery
Copy link

jjeffery commented Apr 9, 2018

I recently ran into an issue that this PR would resolve. I was using the popular github.com/gorilla/securecookie package. This package exports an Error type that implements the causer interface. (See http://www.gorillatoolkit.org/pkg/securecookie#Error).

It turns out that the Cause method can return a nil. This caused me problems, because errors.Cause(err) would return nil for a non-nil err.

While I understand the need to think through the implications of changing the behaviour of errors.Cause, I can't help feeling that there should be a guarantee that errors.Cause should return non-nil when it is passed a non-nil argument.

Thanks

@gregwebs
Copy link

I believe that we accidentally (this is definitely a bug as indicated by the docs) fixed this on our fork

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants