forked from gruntwork-io/terratest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
72 lines (57 loc) · 2.16 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package dns_helper
import "fmt"
// NoResolversError is an error that occurs if no resolvers have been set for DNSLookupE
type NoResolversError struct{}
func (err NoResolversError) Error() string {
return "No resolvers set for DNSLookupE call"
}
// QueryTypeError is an error that occurs if the DNS query type is not supported
type QueryTypeError struct {
Type string
}
func (err QueryTypeError) Error() string {
return fmt.Sprintf("Wrong DNS query type: %s", err.Type)
}
// NotFoundError is an error that occurs if no answer found
type NotFoundError struct {
Query DNSQuery
Nameserver string
}
func (err NotFoundError) Error() string {
return fmt.Sprintf("No %s record found for %s querying nameserver %s", err.Query.Type, err.Query.Name, err.Nameserver)
}
// InconsistentAuthoritativeError is an error that occurs if an authoritative answer is different from another
type InconsistentAuthoritativeError struct {
Query DNSQuery
Answers DNSAnswers
Nameserver string
PreviousAnswers DNSAnswers
}
func (err InconsistentAuthoritativeError) Error() string {
return fmt.Sprintf("Inconsistent authoritative answer from %s to DNS query %s. Got: %s Previous: %s", err.Nameserver, err.Query, err.Answers, err.PreviousAnswers)
}
// NSNotFoundError is an error that occurs if no NS records found
type NSNotFoundError struct {
FQDN string
Nameserver string
}
func (err NSNotFoundError) Error() string {
return fmt.Sprintf("No NS record found for %s up to apex domain %s", err.FQDN, err.Nameserver)
}
// MaxRetriesExceeded is an error that occurs when the maximum amount of retries is exceeded.
type MaxRetriesExceeded struct {
Description string
MaxRetries int
}
func (err MaxRetriesExceeded) Error() string {
return fmt.Sprintf("'%s' unsuccessful after %d retries", err.Description, err.MaxRetries)
}
// ValidationError is an error that occurs when answers validation fails
type ValidationError struct {
Query DNSQuery
Answers DNSAnswers
ExpectedAnswers DNSAnswers
}
func (err ValidationError) Error() string {
return fmt.Sprintf("Unexpected answer to DNS query %s. Got: %s Expected: %s", err.Query, err.Answers, err.ExpectedAnswers)
}