Skip to content

Commit 4929279

Browse files
Merge pull request #508 from penberg/github-explicit-email-error
github: Add ErrNoVerifiedGitHubPrimaryEmail error
2 parents 8333bec + 22a3c4d commit 4929279

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

providers/github/github.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ var (
3333
EmailURL = "https://api.github.com/user/emails"
3434
)
3535

36+
var (
37+
// ErrNoVerifiedGitHubPrimaryEmail user doesn't have verified primary email on GitHub
38+
ErrNoVerifiedGitHubPrimaryEmail = errors.New("The user does not have a verified, primary email address on GitHub")
39+
)
40+
3641
// New creates a new Github provider, and sets up important connection details.
3742
// You should always call `github.New` to get a new Provider. Never try to create
3843
// one manually.
@@ -207,7 +212,7 @@ func getPrivateMail(p *Provider, sess *Session) (email string, err error) {
207212
return v.Email, nil
208213
}
209214
}
210-
return email, fmt.Errorf("The user does not have a verified, primary email address on GitHub")
215+
return email, ErrNoVerifiedGitHubPrimaryEmail
211216
}
212217

213218
func newConfig(provider *Provider, authURL, tokenURL string, scopes []string) *oauth2.Config {

0 commit comments

Comments
 (0)