@@ -70,13 +70,21 @@ func (p *Provider) getRecord(ctx context.Context, client *http.Client,
70
70
switch {
71
71
case err != nil :
72
72
return "" , netip.Addr {}, fmt .Errorf ("json decoding response body: %w" , err )
73
- case parsedJSON .Error != "" :
74
- return "" , netip.Addr {}, fmt .Errorf ("%w: %s" , errors .ErrUnsuccessful , parsedJSON .Error )
73
+ case response .StatusCode == http .StatusBadRequest :
74
+ return "" , netip.Addr {}, fmt .Errorf ("%w: %s" , errors .ErrBadRequest , parsedJSON .Error )
75
+ case response .StatusCode == http .StatusUnauthorized :
76
+ return "" , netip.Addr {}, fmt .Errorf ("%w: %s" , errors .ErrAuth , parsedJSON .Error )
77
+ case response .StatusCode == http .StatusNotFound :
78
+ return "" , netip.Addr {}, fmt .Errorf ("%w: %s" , errors .ErrDomainNotFound , parsedJSON .Error )
75
79
case response .StatusCode != http .StatusOK :
76
80
return "" , netip.Addr {}, fmt .Errorf ("%w: %d: %s" ,
77
81
errors .ErrHTTPStatusNotValid , response .StatusCode , parseJSONErrorOrFullBody (bodyBytes ))
82
+ case parsedJSON .Error != "" :
83
+ return "" , netip.Addr {}, fmt .Errorf ("%w: %s" , errors .ErrUnsuccessful , parsedJSON .Error )
78
84
}
79
85
86
+ // Status is OK (200) and error field is empty
87
+
80
88
for _ , record := range parsedJSON .Records {
81
89
if record .Name != p .owner || record .Type != recordType {
82
90
continue
0 commit comments