generated from resonatecoop/id-server-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
errors.go
33 lines (29 loc) · 1.02 KB
/
errors.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
package oauth
import (
"net/http"
)
var (
errStatusCodeMap = map[error]int{
ErrAuthorizationCodeNotFound: http.StatusNotFound,
ErrAuthorizationCodeExpired: http.StatusBadRequest,
ErrInvalidRedirectURI: http.StatusBadRequest,
ErrInvalidScope: http.StatusBadRequest,
ErrInvalidUsernameOrPassword: http.StatusBadRequest,
ErrRefreshTokenNotFound: http.StatusNotFound,
ErrRefreshTokenExpired: http.StatusBadRequest,
ErrRequestedScopeCannotBeGreater: http.StatusBadRequest,
ErrTokenHintInvalid: http.StatusBadRequest,
ErrAccessTokenNotFound: http.StatusNotFound,
ErrRefreshTokenNotFound: http.StatusNotFound,
ErrTokenMissing: http.StatusBadRequest,
ErrTokenHintInvalid: http.StatusBadRequest,
ErrInvalidUsernameOrPassword: http.StatusUnauthorized,
}
)
func getErrStatusCode(err error) int {
code, ok := errStatusCodeMap[err]
if ok {
return code
}
return http.StatusInternalServerError
}