forked from strava/go.strava
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
38 lines (31 loc) · 876 Bytes
/
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
34
35
36
37
38
package strava
import (
"encoding/json"
)
type Error struct {
Message string `json:"message"`
Errors []*ErrorDetailed `json:"errors"`
}
type ErrorDetailed struct {
Resource string `json:"resource"`
Field string `json:"field"`
Code string `json:"code"`
}
func (e Error) Error() string {
b, _ := json.Marshal(e)
return string(b)
}
// returned during oauth if there was a user caused problem
// such as user did not grant access or the id/secret was invalid
type OAuthError struct {
message string
}
func (e *OAuthError) Error() string {
return e.message
}
var (
OAuthAuthorizationDeniedErr = &OAuthError{"authorization denied by user"}
OAuthInvalidCredentialsErr = &OAuthError{"invalid client_id or client_secret"}
OAuthInvalidCodeErr = &OAuthError{"unrecognized code"}
OAuthServerErr = &OAuthError{"server error"}
)