-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherr_code.go
More file actions
44 lines (34 loc) · 1.32 KB
/
err_code.go
File metadata and controls
44 lines (34 loc) · 1.32 KB
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 whoisparser
// ErrCode contains the numeric error code
type ErrCode int
const (
// ErrCodeNoError is returned when no request errors encountered
ErrCodeNoError ErrCode = 0
// ErrCodeNoSuchDomain is returned when we've got "no such domain" error
ErrCodeNoSuchDomain ErrCode = 1
// ErrCodeRequestRateLimit is returned when the request rate limit reached
ErrCodeRequestRateLimit ErrCode = 2
// ErrCodeMalformedRequest is returned when a malformed request sent
ErrCodeMalformedRequest ErrCode = 3
// ErrCodeTldHasNoServer is returned when the requested TLD has no whois server
ErrCodeTldHasNoServer ErrCode = 4
// ErrCodeEmptyWhois is returned when the whois text is empty
ErrCodeEmptyWhois ErrCode = 5
// ErrCodeNoErrorRegex is returned when the error checking regular expressions
// are not set for current parser
ErrCodeNoErrorRegex ErrCode = 6
)
var (
errCodeDescription = map[ErrCode]string{
ErrCodeNoError: "no errors",
ErrCodeNoSuchDomain: "no such domain",
ErrCodeRequestRateLimit: "request rate limit reached",
ErrCodeMalformedRequest: "malformed request",
ErrCodeTldHasNoServer: "TLD has no server",
ErrCodeEmptyWhois: "whois is empty",
}
)
// GetErrCodeDescription returns error code description
func GetErrCodeDescription(code ErrCode) string {
return errCodeDescription[code]
}