-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.go
44 lines (37 loc) · 1.16 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package errors
import "fmt"
//AuthenticationProviderNotSupported happens when a query should return a document but it's not found
type AuthenticationProviderNotSupported struct {
Provider string
}
//NewAuthenticationProviderNotSupported creates a new error
func NewAuthenticationProviderNotSupported(provider string) *AuthenticationProviderNotSupported {
return &AuthenticationProviderNotSupported{
Provider: provider,
}
}
//Error string
func (err AuthenticationProviderNotSupported) Error() string {
return fmt.Sprintf("Provider %s is not supported.", err.Provider)
}
//AuthenticationFailed happens when an authentication provider does not recognize the access token
type AuthenticationFailed struct {
Provider, UserID, Token string
}
//NewAuthenticationFailed creates a new error
func NewAuthenticationFailed(provider, userID, token string) *AuthenticationFailed {
return &AuthenticationFailed{
Provider: provider,
UserID: userID,
Token: token,
}
}
//Error string
func (err AuthenticationFailed) Error() string {
return fmt.Sprintf(
"Authentication with provider %s for user %s failed (Access Token: %s).",
err.Provider,
err.UserID,
err.Token,
)
}