-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponse.go
43 lines (39 loc) · 1.13 KB
/
response.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
package gorecaptcha
import (
"errors"
)
//
type recaptchaResponse struct {
Status bool
Err error
}
var (
// ErrInvalidSitePrivateKey error response type
ErrInvalidSitePrivateKey = errors.New("Invalid site private key")
// ErrInvalidRequestCookie error response type
ErrInvalidRequestCookie = errors.New("Invalid request coookie")
// ErrIncorrectCaptchaSol error response type
ErrIncorrectCaptchaSol = errors.New("Incorrect captcha sol")
// ErrCaptchaTimeout error response type
ErrCaptchaTimeout = errors.New("Captcha timeout")
// ErrRecaptchaNotReachable error response type
ErrRecaptchaNotReachable = errors.New("Recaptcha not reachable")
// ErrUnknown error response type
ErrUnknown = errors.New("Recaptcha not supported error")
)
func parseErrorLine(line string) error {
switch line {
case "invalid-site-private-key":
return ErrInvalidSitePrivateKey
case "invalid-request-cookie":
return ErrInvalidRequestCookie
case "incorrect-captcha-sol":
return ErrIncorrectCaptchaSol
case "captcha-timeout":
return ErrCaptchaTimeout
case "recaptcha-not-reachable":
return ErrRecaptchaNotReachable
default:
return ErrUnknown
}
}