Skip to content

Commit

Permalink
PORKBUN: catch error on parsing api (#3012)
Browse files Browse the repository at this point in the history
  • Loading branch information
imlonghao authored Jun 17, 2024
1 parent 2344257 commit 174fd7b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions providers/porkbun/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ func (c *porkbunProvider) getRecords(domain string) ([]domainRecord, error) {
}

var dr recordResponse
json.Unmarshal(bodyString, &dr)
err = json.Unmarshal(bodyString, &dr)
if err != nil {
return nil, fmt.Errorf("failed parsing record list from porkbun: %w", err)
}

var records []domainRecord
for _, rec := range dr.Records {
Expand All @@ -154,7 +157,10 @@ func (c *porkbunProvider) getNameservers(domain string) ([]string, error) {
}

var ns nsResponse
json.Unmarshal(bodyString, &ns)
err = json.Unmarshal(bodyString, &ns)
if err != nil {
return nil, fmt.Errorf("failed parsing nameserver list from porkbun: %w", err)
}

sort.Strings(ns.Nameservers)

Expand Down Expand Up @@ -185,7 +191,10 @@ func (c *porkbunProvider) listAllDomains() ([]string, error) {
}

var dlr domainListResponse
json.Unmarshal(bodyString, &dlr)
err = json.Unmarshal(bodyString, &dlr)
if err != nil {
return nil, fmt.Errorf("failed parsing domain list from porkbun: %w", err)
}

var domains []string
for _, domain := range dlr.Domains {
Expand Down

0 comments on commit 174fd7b

Please sign in to comment.